Powershell question.
I am trying to change local user password on multiple remote servers that are on different domains. The csv file contains 4 columns: servername, domain, password, localuser
Example:
- Server1, mydomain.dev, test123, localadmin
- Server2, mydomain.uat, test123, localadmin
- Server3, mydomain.prod test123, localadmin
Here is what i have so far but sadly with no success:
Import-CSV servers.csv | ForEach-Object {Invoke-Command -ComputerName "$($_.servername).$($_.domain)" `
-Credential "$($_.domain)\$($env:username)" {([adsi]"WinNT://./$_.localuser").SetPassword($_.password)}
}
Being fairly new to Powershell I am at a loss how to pass locauser and password properties inside {} properly.
Any help is greatly appreciated!