Question

I have several domains and one admin account in each one. It is a great pain to log into each domain to change password every month.. I have therefore written a script that will connect to all domains and check to see if I have already changed the password or if I am still using the old one. If I am using the old one the script should update it.

I connect to the domains (sequentially) with

$oldPassword = Read-Host "Enter old password" -AsSecureString
$newPassword = Read-Host "Enter new password" -AsSecureString
$oldCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "$domain\$adminusername",$oldPassword
Connect-QADService -Service $domain -Credential $oldCredentials

and if I get a successfull connection with $oldcredentials I try to change pwd with

GET-QADUSER $adminusername | SET-QADUSER -UserPassword $newPassword

I am guessing that I am not passing the secure string correctly to SET-QADUSER but I've found no documentation on another way to do it.

Please advice:)

Était-ce utile?

La solution

SET-QADUSER -UserPassword accept [string] type not [System.Security.SecureString].

Try to pass just a string as password.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top