mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
17 lines
433 B
PowerShell
17 lines
433 B
PowerShell
trap
|
|
{
|
|
Write-Error -ErrorRecord $_
|
|
exit 1;
|
|
}
|
|
|
|
$username = $args[0]
|
|
[void][system.reflection.assembly]::LoadWithPartialName('System.DirectoryServices.AccountManagement')
|
|
$pc = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext 'Machine', $env:COMPUTERNAME
|
|
For ($i = 1; $i -le 10; $i++) {
|
|
try {
|
|
$pc.ValidateCredentials($username, 'b@DP@ssw0rd')
|
|
}
|
|
catch {
|
|
break
|
|
}
|
|
}
|