Reputation: 21
I am having issues with the code written below. What the code is supposed to do is grab a list of predefined users and then attempt to test 3 passwords against the users' accounts. (Full code has been placed below in the answers) I keep receiving errors within the code as stated above in the title. Could any one help me figure this out? I always come here looking for answers as you guys are the best! Today I am unable to figure this out.
$cred = New-Object -TypeName System.Management.Automation.PSCredential Argumentlist $account, $entry
foreach ($account in $accountfile){
try {
get-aduser “username” -credential $cred
$array += New-Object psobject -property @{'Account'=$account;'Password'=$entry}
}
catch { Write-Host "There was an issue"}
}
}
$count++#increase counter
}
$newpass=$newpass[3..$newpass.count] #subtract the first 3 entries from the $newpass array
$count= 0 #reset counter to zero
Upvotes: 2
Views: 8409
Reputation: 18156
You missed the - on ArgumentList.
$cred = New-Object -TypeName System.Management.Automation.PSCredential -Argumentlist $account, $entry
Upvotes: 3