PowerShell script error “Unexpected token 'h' in expression or statement. The string is missing the terminator:”










2














I have the following code inside my console application to get a server information using PowerShell:



string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "';$vCenterAdmin = '" + vCenterUsername.Trim() + "' ;$vCenterPassword = '" + vCenterPassword + "';" + System.Environment.NewLine;

PsCmd = PsCmd + "$VIServer = Connect-VIServer -Server $vCenterServer -User $vCenterAdmin -Password $vCenterPassword;" + System.Environment.NewLine;

PsCmd = PsCmd + "Get-VMHost " + System.Environment.NewLine;


Now the script is working well on the 150 servers we have, but on a single server I am getting this exception:




At line:1 char:131 + ... !*******(********6'*;*****'; + ~
Unexpected token 'h' in expression or statement. At line:1 char:135 +
... *
*(******';'; + ~~ The string is missing the terminator: '. |
ABC




Which is raising an error on the password variable. And in my case I am getting the password from an external RESP API. Now the password have this format:



"************


Where it starts with 2 reserved characters ", and the JSON object which I get will be as follow "PASSWORD":""*******".. so could the problem be that the password contains reserved set of characters "?? And how I can fix this?










share|improve this question




























    2














    I have the following code inside my console application to get a server information using PowerShell:



    string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "';$vCenterAdmin = '" + vCenterUsername.Trim() + "' ;$vCenterPassword = '" + vCenterPassword + "';" + System.Environment.NewLine;

    PsCmd = PsCmd + "$VIServer = Connect-VIServer -Server $vCenterServer -User $vCenterAdmin -Password $vCenterPassword;" + System.Environment.NewLine;

    PsCmd = PsCmd + "Get-VMHost " + System.Environment.NewLine;


    Now the script is working well on the 150 servers we have, but on a single server I am getting this exception:




    At line:1 char:131 + ... !*******(********6'*;*****'; + ~
    Unexpected token 'h' in expression or statement. At line:1 char:135 +
    ... *
    *(******';'; + ~~ The string is missing the terminator: '. |
    ABC




    Which is raising an error on the password variable. And in my case I am getting the password from an external RESP API. Now the password have this format:



    "************


    Where it starts with 2 reserved characters ", and the JSON object which I get will be as follow "PASSWORD":""*******".. so could the problem be that the password contains reserved set of characters "?? And how I can fix this?










    share|improve this question


























      2












      2








      2







      I have the following code inside my console application to get a server information using PowerShell:



      string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "';$vCenterAdmin = '" + vCenterUsername.Trim() + "' ;$vCenterPassword = '" + vCenterPassword + "';" + System.Environment.NewLine;

      PsCmd = PsCmd + "$VIServer = Connect-VIServer -Server $vCenterServer -User $vCenterAdmin -Password $vCenterPassword;" + System.Environment.NewLine;

      PsCmd = PsCmd + "Get-VMHost " + System.Environment.NewLine;


      Now the script is working well on the 150 servers we have, but on a single server I am getting this exception:




      At line:1 char:131 + ... !*******(********6'*;*****'; + ~
      Unexpected token 'h' in expression or statement. At line:1 char:135 +
      ... *
      *(******';'; + ~~ The string is missing the terminator: '. |
      ABC




      Which is raising an error on the password variable. And in my case I am getting the password from an external RESP API. Now the password have this format:



      "************


      Where it starts with 2 reserved characters ", and the JSON object which I get will be as follow "PASSWORD":""*******".. so could the problem be that the password contains reserved set of characters "?? And how I can fix this?










      share|improve this question















      I have the following code inside my console application to get a server information using PowerShell:



      string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "';$vCenterAdmin = '" + vCenterUsername.Trim() + "' ;$vCenterPassword = '" + vCenterPassword + "';" + System.Environment.NewLine;

      PsCmd = PsCmd + "$VIServer = Connect-VIServer -Server $vCenterServer -User $vCenterAdmin -Password $vCenterPassword;" + System.Environment.NewLine;

      PsCmd = PsCmd + "Get-VMHost " + System.Environment.NewLine;


      Now the script is working well on the 150 servers we have, but on a single server I am getting this exception:




      At line:1 char:131 + ... !*******(********6'*;*****'; + ~
      Unexpected token 'h' in expression or statement. At line:1 char:135 +
      ... *
      *(******';'; + ~~ The string is missing the terminator: '. |
      ABC




      Which is raising an error on the password variable. And in my case I am getting the password from an external RESP API. Now the password have this format:



      "************


      Where it starts with 2 reserved characters ", and the JSON object which I get will be as follow "PASSWORD":""*******".. so could the problem be that the password contains reserved set of characters "?? And how I can fix this?







      c# string powershell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 17:40

























      asked Nov 12 at 14:41









      test test

      40861232




      40861232






















          2 Answers
          2






          active

          oldest

          votes


















          1















          Now the password have this format:



          "*******


          Where it starts with 2 reserved characters "




          If your passwords really come from JSON such as "PASSWORD":""*******", your passwords do not start with " - they start with ", because the is simply a JSON escape character needed to embed a literal " in char. in an (always double-quoted) JSON string value.



          In other words: If you parse your JSON correctly, the actual password value will be:



          "*******


          You can verify this as follows:



          PS> (' "PASSWORD": ""*******" ' | ConvertFrom-Json).PASSWORD
          "*******



          Your next problem is that you're embedding the password in a string representing PowerShell source code, and inside that string you're using (embedded) single-quoting ('...') to surround the value[1].

          In order to do that, you must escape value-embedded ' instances as '' so as not to cause a syntax error when PowerShell later parses the code:



          // Note the .Replace() calls
          string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" +
          vCenterName.Trim().Replace("'", "''") + "';$vCenterAdmin = '" +
          vCenterUsername.Trim().Replace("'", "''") +
          "' ;$vCenterPassword = '" + vCenterPassword.Replace("'", "''") + "';" +
          System.Environment.NewLine;


          With a literal password value of "***'*** (and sample values for the center and username), C# variable PSCmd will receive a string with the following literal contents:



          add-pssnapin VMware.VimAutomation.Core; $vCenterServer = 'center1';$vCenterAdmin = 'jdoe' ;$vCenterPassword = '"***''***';



          [1] And single quotes are the right choice, because using double quotes could result in unwanted interpretation (string interpolation) of the embedded value by PowerShell.






          share|improve this answer




















          • now your code work for me also.. where i simple replace vCenterPassword with vCenterPassword.Replace("'", "''").. but i am not sure how your replace method worked exactly? as having two '' instead of one ' should produce different password is this correct?
            – test test
            Nov 12 at 23:28






          • 1




            @testtest: No: By using '' you simply escape what ends up being a single ' in the resulting string. It is merely a syntax requirement, just as " in the JSON input was necessary to produce a literal ".
            – mklement0
            Nov 12 at 23:34



















          1














          You need to escape the ". You do this in PowerShell using the ` character, e.g. `"



          Try this:



          string PsCmd = "Add-PSSnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "'; $vCenterAdmin = '" + vCenterUsername.Trim() + "'; $vCenterPassword = "" + vCenterPassword.Replace(""", "`"") + "";" + System.Environment.NewLine;





          share|improve this answer






















          • can you please explain this in more details? what i need to do inside my code?
            – test test
            Nov 12 at 14:47











          • thanks for the edit,, so in this case the " inside the password will be replaced by `" ??
            – test test
            Nov 12 at 14:57







          • 1




            @testtest yes, that's correct
            – Jon Grant
            Nov 12 at 14:57










          • @JonGrant but if the " is going to be replaced by `" so this will produce wrong password?
            – test test
            Nov 12 at 15:50






          • 1




            @testtest No, the `` is ignored. Is it possible the password contains a single quote? ' In this case, perhaps change the code as per my edited example
            – Jon Grant
            Nov 12 at 15:58










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264505%2fpowershell-script-error-unexpected-token-h-in-expression-or-statement-the-st%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1















          Now the password have this format:



          "*******


          Where it starts with 2 reserved characters "




          If your passwords really come from JSON such as "PASSWORD":""*******", your passwords do not start with " - they start with ", because the is simply a JSON escape character needed to embed a literal " in char. in an (always double-quoted) JSON string value.



          In other words: If you parse your JSON correctly, the actual password value will be:



          "*******


          You can verify this as follows:



          PS> (' "PASSWORD": ""*******" ' | ConvertFrom-Json).PASSWORD
          "*******



          Your next problem is that you're embedding the password in a string representing PowerShell source code, and inside that string you're using (embedded) single-quoting ('...') to surround the value[1].

          In order to do that, you must escape value-embedded ' instances as '' so as not to cause a syntax error when PowerShell later parses the code:



          // Note the .Replace() calls
          string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" +
          vCenterName.Trim().Replace("'", "''") + "';$vCenterAdmin = '" +
          vCenterUsername.Trim().Replace("'", "''") +
          "' ;$vCenterPassword = '" + vCenterPassword.Replace("'", "''") + "';" +
          System.Environment.NewLine;


          With a literal password value of "***'*** (and sample values for the center and username), C# variable PSCmd will receive a string with the following literal contents:



          add-pssnapin VMware.VimAutomation.Core; $vCenterServer = 'center1';$vCenterAdmin = 'jdoe' ;$vCenterPassword = '"***''***';



          [1] And single quotes are the right choice, because using double quotes could result in unwanted interpretation (string interpolation) of the embedded value by PowerShell.






          share|improve this answer




















          • now your code work for me also.. where i simple replace vCenterPassword with vCenterPassword.Replace("'", "''").. but i am not sure how your replace method worked exactly? as having two '' instead of one ' should produce different password is this correct?
            – test test
            Nov 12 at 23:28






          • 1




            @testtest: No: By using '' you simply escape what ends up being a single ' in the resulting string. It is merely a syntax requirement, just as " in the JSON input was necessary to produce a literal ".
            – mklement0
            Nov 12 at 23:34
















          1















          Now the password have this format:



          "*******


          Where it starts with 2 reserved characters "




          If your passwords really come from JSON such as "PASSWORD":""*******", your passwords do not start with " - they start with ", because the is simply a JSON escape character needed to embed a literal " in char. in an (always double-quoted) JSON string value.



          In other words: If you parse your JSON correctly, the actual password value will be:



          "*******


          You can verify this as follows:



          PS> (' "PASSWORD": ""*******" ' | ConvertFrom-Json).PASSWORD
          "*******



          Your next problem is that you're embedding the password in a string representing PowerShell source code, and inside that string you're using (embedded) single-quoting ('...') to surround the value[1].

          In order to do that, you must escape value-embedded ' instances as '' so as not to cause a syntax error when PowerShell later parses the code:



          // Note the .Replace() calls
          string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" +
          vCenterName.Trim().Replace("'", "''") + "';$vCenterAdmin = '" +
          vCenterUsername.Trim().Replace("'", "''") +
          "' ;$vCenterPassword = '" + vCenterPassword.Replace("'", "''") + "';" +
          System.Environment.NewLine;


          With a literal password value of "***'*** (and sample values for the center and username), C# variable PSCmd will receive a string with the following literal contents:



          add-pssnapin VMware.VimAutomation.Core; $vCenterServer = 'center1';$vCenterAdmin = 'jdoe' ;$vCenterPassword = '"***''***';



          [1] And single quotes are the right choice, because using double quotes could result in unwanted interpretation (string interpolation) of the embedded value by PowerShell.






          share|improve this answer




















          • now your code work for me also.. where i simple replace vCenterPassword with vCenterPassword.Replace("'", "''").. but i am not sure how your replace method worked exactly? as having two '' instead of one ' should produce different password is this correct?
            – test test
            Nov 12 at 23:28






          • 1




            @testtest: No: By using '' you simply escape what ends up being a single ' in the resulting string. It is merely a syntax requirement, just as " in the JSON input was necessary to produce a literal ".
            – mklement0
            Nov 12 at 23:34














          1












          1








          1







          Now the password have this format:



          "*******


          Where it starts with 2 reserved characters "




          If your passwords really come from JSON such as "PASSWORD":""*******", your passwords do not start with " - they start with ", because the is simply a JSON escape character needed to embed a literal " in char. in an (always double-quoted) JSON string value.



          In other words: If you parse your JSON correctly, the actual password value will be:



          "*******


          You can verify this as follows:



          PS> (' "PASSWORD": ""*******" ' | ConvertFrom-Json).PASSWORD
          "*******



          Your next problem is that you're embedding the password in a string representing PowerShell source code, and inside that string you're using (embedded) single-quoting ('...') to surround the value[1].

          In order to do that, you must escape value-embedded ' instances as '' so as not to cause a syntax error when PowerShell later parses the code:



          // Note the .Replace() calls
          string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" +
          vCenterName.Trim().Replace("'", "''") + "';$vCenterAdmin = '" +
          vCenterUsername.Trim().Replace("'", "''") +
          "' ;$vCenterPassword = '" + vCenterPassword.Replace("'", "''") + "';" +
          System.Environment.NewLine;


          With a literal password value of "***'*** (and sample values for the center and username), C# variable PSCmd will receive a string with the following literal contents:



          add-pssnapin VMware.VimAutomation.Core; $vCenterServer = 'center1';$vCenterAdmin = 'jdoe' ;$vCenterPassword = '"***''***';



          [1] And single quotes are the right choice, because using double quotes could result in unwanted interpretation (string interpolation) of the embedded value by PowerShell.






          share|improve this answer













          Now the password have this format:



          "*******


          Where it starts with 2 reserved characters "




          If your passwords really come from JSON such as "PASSWORD":""*******", your passwords do not start with " - they start with ", because the is simply a JSON escape character needed to embed a literal " in char. in an (always double-quoted) JSON string value.



          In other words: If you parse your JSON correctly, the actual password value will be:



          "*******


          You can verify this as follows:



          PS> (' "PASSWORD": ""*******" ' | ConvertFrom-Json).PASSWORD
          "*******



          Your next problem is that you're embedding the password in a string representing PowerShell source code, and inside that string you're using (embedded) single-quoting ('...') to surround the value[1].

          In order to do that, you must escape value-embedded ' instances as '' so as not to cause a syntax error when PowerShell later parses the code:



          // Note the .Replace() calls
          string PsCmd = "add-pssnapin VMware.VimAutomation.Core; $vCenterServer = '" +
          vCenterName.Trim().Replace("'", "''") + "';$vCenterAdmin = '" +
          vCenterUsername.Trim().Replace("'", "''") +
          "' ;$vCenterPassword = '" + vCenterPassword.Replace("'", "''") + "';" +
          System.Environment.NewLine;


          With a literal password value of "***'*** (and sample values for the center and username), C# variable PSCmd will receive a string with the following literal contents:



          add-pssnapin VMware.VimAutomation.Core; $vCenterServer = 'center1';$vCenterAdmin = 'jdoe' ;$vCenterPassword = '"***''***';



          [1] And single quotes are the right choice, because using double quotes could result in unwanted interpretation (string interpolation) of the embedded value by PowerShell.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 18:30









          mklement0

          126k20239267




          126k20239267











          • now your code work for me also.. where i simple replace vCenterPassword with vCenterPassword.Replace("'", "''").. but i am not sure how your replace method worked exactly? as having two '' instead of one ' should produce different password is this correct?
            – test test
            Nov 12 at 23:28






          • 1




            @testtest: No: By using '' you simply escape what ends up being a single ' in the resulting string. It is merely a syntax requirement, just as " in the JSON input was necessary to produce a literal ".
            – mklement0
            Nov 12 at 23:34

















          • now your code work for me also.. where i simple replace vCenterPassword with vCenterPassword.Replace("'", "''").. but i am not sure how your replace method worked exactly? as having two '' instead of one ' should produce different password is this correct?
            – test test
            Nov 12 at 23:28






          • 1




            @testtest: No: By using '' you simply escape what ends up being a single ' in the resulting string. It is merely a syntax requirement, just as " in the JSON input was necessary to produce a literal ".
            – mklement0
            Nov 12 at 23:34
















          now your code work for me also.. where i simple replace vCenterPassword with vCenterPassword.Replace("'", "''").. but i am not sure how your replace method worked exactly? as having two '' instead of one ' should produce different password is this correct?
          – test test
          Nov 12 at 23:28




          now your code work for me also.. where i simple replace vCenterPassword with vCenterPassword.Replace("'", "''").. but i am not sure how your replace method worked exactly? as having two '' instead of one ' should produce different password is this correct?
          – test test
          Nov 12 at 23:28




          1




          1




          @testtest: No: By using '' you simply escape what ends up being a single ' in the resulting string. It is merely a syntax requirement, just as " in the JSON input was necessary to produce a literal ".
          – mklement0
          Nov 12 at 23:34





          @testtest: No: By using '' you simply escape what ends up being a single ' in the resulting string. It is merely a syntax requirement, just as " in the JSON input was necessary to produce a literal ".
          – mklement0
          Nov 12 at 23:34














          1














          You need to escape the ". You do this in PowerShell using the ` character, e.g. `"



          Try this:



          string PsCmd = "Add-PSSnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "'; $vCenterAdmin = '" + vCenterUsername.Trim() + "'; $vCenterPassword = "" + vCenterPassword.Replace(""", "`"") + "";" + System.Environment.NewLine;





          share|improve this answer






















          • can you please explain this in more details? what i need to do inside my code?
            – test test
            Nov 12 at 14:47











          • thanks for the edit,, so in this case the " inside the password will be replaced by `" ??
            – test test
            Nov 12 at 14:57







          • 1




            @testtest yes, that's correct
            – Jon Grant
            Nov 12 at 14:57










          • @JonGrant but if the " is going to be replaced by `" so this will produce wrong password?
            – test test
            Nov 12 at 15:50






          • 1




            @testtest No, the `` is ignored. Is it possible the password contains a single quote? ' In this case, perhaps change the code as per my edited example
            – Jon Grant
            Nov 12 at 15:58















          1














          You need to escape the ". You do this in PowerShell using the ` character, e.g. `"



          Try this:



          string PsCmd = "Add-PSSnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "'; $vCenterAdmin = '" + vCenterUsername.Trim() + "'; $vCenterPassword = "" + vCenterPassword.Replace(""", "`"") + "";" + System.Environment.NewLine;





          share|improve this answer






















          • can you please explain this in more details? what i need to do inside my code?
            – test test
            Nov 12 at 14:47











          • thanks for the edit,, so in this case the " inside the password will be replaced by `" ??
            – test test
            Nov 12 at 14:57







          • 1




            @testtest yes, that's correct
            – Jon Grant
            Nov 12 at 14:57










          • @JonGrant but if the " is going to be replaced by `" so this will produce wrong password?
            – test test
            Nov 12 at 15:50






          • 1




            @testtest No, the `` is ignored. Is it possible the password contains a single quote? ' In this case, perhaps change the code as per my edited example
            – Jon Grant
            Nov 12 at 15:58













          1












          1








          1






          You need to escape the ". You do this in PowerShell using the ` character, e.g. `"



          Try this:



          string PsCmd = "Add-PSSnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "'; $vCenterAdmin = '" + vCenterUsername.Trim() + "'; $vCenterPassword = "" + vCenterPassword.Replace(""", "`"") + "";" + System.Environment.NewLine;





          share|improve this answer














          You need to escape the ". You do this in PowerShell using the ` character, e.g. `"



          Try this:



          string PsCmd = "Add-PSSnapin VMware.VimAutomation.Core; $vCenterServer = '" + vCenterName.Trim() + "'; $vCenterAdmin = '" + vCenterUsername.Trim() + "'; $vCenterPassword = "" + vCenterPassword.Replace(""", "`"") + "";" + System.Environment.NewLine;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 at 15:58

























          answered Nov 12 at 14:46









          Jon Grant

          10k23153




          10k23153











          • can you please explain this in more details? what i need to do inside my code?
            – test test
            Nov 12 at 14:47











          • thanks for the edit,, so in this case the " inside the password will be replaced by `" ??
            – test test
            Nov 12 at 14:57







          • 1




            @testtest yes, that's correct
            – Jon Grant
            Nov 12 at 14:57










          • @JonGrant but if the " is going to be replaced by `" so this will produce wrong password?
            – test test
            Nov 12 at 15:50






          • 1




            @testtest No, the `` is ignored. Is it possible the password contains a single quote? ' In this case, perhaps change the code as per my edited example
            – Jon Grant
            Nov 12 at 15:58
















          • can you please explain this in more details? what i need to do inside my code?
            – test test
            Nov 12 at 14:47











          • thanks for the edit,, so in this case the " inside the password will be replaced by `" ??
            – test test
            Nov 12 at 14:57







          • 1




            @testtest yes, that's correct
            – Jon Grant
            Nov 12 at 14:57










          • @JonGrant but if the " is going to be replaced by `" so this will produce wrong password?
            – test test
            Nov 12 at 15:50






          • 1




            @testtest No, the `` is ignored. Is it possible the password contains a single quote? ' In this case, perhaps change the code as per my edited example
            – Jon Grant
            Nov 12 at 15:58















          can you please explain this in more details? what i need to do inside my code?
          – test test
          Nov 12 at 14:47





          can you please explain this in more details? what i need to do inside my code?
          – test test
          Nov 12 at 14:47













          thanks for the edit,, so in this case the " inside the password will be replaced by `" ??
          – test test
          Nov 12 at 14:57





          thanks for the edit,, so in this case the " inside the password will be replaced by `" ??
          – test test
          Nov 12 at 14:57





          1




          1




          @testtest yes, that's correct
          – Jon Grant
          Nov 12 at 14:57




          @testtest yes, that's correct
          – Jon Grant
          Nov 12 at 14:57












          @JonGrant but if the " is going to be replaced by `" so this will produce wrong password?
          – test test
          Nov 12 at 15:50




          @JonGrant but if the " is going to be replaced by `" so this will produce wrong password?
          – test test
          Nov 12 at 15:50




          1




          1




          @testtest No, the `` is ignored. Is it possible the password contains a single quote? ' In this case, perhaps change the code as per my edited example
          – Jon Grant
          Nov 12 at 15:58




          @testtest No, the `` is ignored. Is it possible the password contains a single quote? ' In this case, perhaps change the code as per my edited example
          – Jon Grant
          Nov 12 at 15:58

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264505%2fpowershell-script-error-unexpected-token-h-in-expression-or-statement-the-st%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党