Alright, I am beating my brains in over here. I am trying to query AD for a list of computers based on OS Type and change the passwords accordingly. I can query AD and find all of the computers, but when I try to use it in the array, it uses the Distinguished Name instead of the Name Field.
$OSList = Get-ADComputer -Filter {OperatingSystem -Like '*Windows*'} -Properties OperatingSystem | Select Name,OperatingSystem foreach ($OS in $OSList) { if ($OS.OperatingSystem -like 'Windows Server*') { ([ADSI]"WinNT://$($OS.Name)/Admin").SetPassword('NewPassword') } if ($OS.OperatingSystem -like 'Windows 7*') { ([ADSI]"WinNT://$($OS.Name)/Admin").SetPassword('NewPassword') } Write-Host "Changing Admin Password on $OS.Name" }
I keep getting the error "The Network Path was not found", because it is reading $OS as the Distinguished Name. I am sure I just have my variables mixed up somehow. Any help would be greatly appreciated.
Respectfully,
Chris Priester