ADSI Does Not Accept Specific Passwords

This topic contains 3 replies, has 4 voices, and was last updated by Profile photo of Ron Ron 4 months ago.

  • Author
    Posts
  • #62167
    Profile photo of Jason Colotario
    Jason Colotario
    Participant

    Problem is: Example #1 password is treated as two literals being that I have the double quote smack dab in the middle of the password.

    Problem is: Example #2 password is treated as a variable starting at the dollar sign character.

    EXAMPLE #1:
    [ADSI]$Admin4="WinNT://$env:COMPUTERNAME/dsmith"
    $Admin4.SetPassword("dds"ex6722!")

    EXAMPLE #2:
    [ADSI]$Admin5="WinNT://$env:COMPUTERNAME/gjohnson"
    $Admin5.SetPassword("p88$Top60")

    How can I fix this syntactical issue so that ADSI accepts these types of passwords via POSH. Is it possible to resolve this?

    Many thanks!

  • #62175
    Profile photo of random commandline
    random commandline
    Participant

    Use single quotes not double. ('dds"ex6722!') ('p88$Top60')

    • #62208
      Profile photo of Mark Prior
      Mark Prior
      Participant

      as you say you can you single quotes, however I would hazard a guess that the password generator (i assume your using one?) may spit out those also.

      i would go along the lines of excluding the single quotes in the password generation then all will be fine, i came accross something similar, using MS Orchestrator.

    • #62235
      Profile photo of Ron
      Ron
      Participant

      You can double up the single quotes and still make it work, but means you have to remember to do that.

      Assuming you're running these commands interactively and either typing or pasting in the passwords, use a prompt to avoid having to escape any characters.

      $Admin5.SetPassword((read-host "Enter password"))

      If you are writing a one off script, you can use here-strings to avoid escaping characters.

      $h=@'
      abd'"$b23
      '@

      $Admin5.SetPassword($h)

You must be logged in to reply to this topic.