VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Need help in validating the password

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this Re: invoke-vmscript to check guest passwords


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Sorry, but how has this anything to do with PowerCLI?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

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 ?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could do something like this Re: invoke-vmscript to check guest passwords


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much LucD. That worked perfectly Smiley Happy

0 Kudos