Hi,
I need help in validating the VMs password. using the below script I am unable to validate as it is showing true for everything.
Please help
$computers = Get-Content -path ".\computers.txt"
$report = foreach ($Computer in $Computers) {
$Computer = $Computer.toupper()
$Isonline = "OFFLINE"
$StatsError ="Failed"
if((Test-Connection -ComputerName $Computer -count 1 -ErrorAction 0)) {
$Isonline = "ONLINE"
} else { $StatsError= "`t$Computer is OFFLINE" }
try {
Add-Type -assemblyname system.DirectoryServices.accountmanagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
$StatsError = $DS.ValidateCredentials("administrator", "password@123")
}
catch {
$StatsError="$_"
}
$obj = New-Object -TypeName PSObject -Property @{
ComputerName = $Computer
IsOnline = $Isonline
PasswordValidation=$StatsError
}
$obj | Select ComputerName, IsOnline, PasswordValidation
$obj | Select ComputerName, IsOnline, PasswordValidation | Export-Csv -Append -Path "output.csv" -NoTypeInformation -UseCulture
}
$report | ft -auto
You could do something like this Re: invoke-vmscript to check guest passwords
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry, but how has this anything to do with PowerCLI?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I know, it is not related to PowerCLI but I need your help in validating the passwords for all VMs which the passwords were changed.
Or Is there a way to validate the credentails using Invoke-VMScript ?
You could do something like this Re: invoke-vmscript to check guest passwords
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much LucD. That worked perfectly