Hi,
I am unable to validate and execute the below scripts, When I have multiple passwords
Please help
$reportlocation1 = ".\Clients_Mgmt.csv"
$WPassword = "Password1", "Password2", "Password3"
$pass = ConvertTo-SecureString -AsPlainText $WPassword -Force
$Creds = New-Object System.Management.Automation.PSCredential ("admin", $pass)
$code = @'
"### Output ###"
(Get-Date)
'@
$report = @()
Import-Csv -Path $reportlocation1 -UseCulture -PipelineVariable row |
ForEach-Object -Process {
foreach ($pswd in $pass)
{
$sInvoke = @{
VM = $_.Name
GuestCredential = $Creds
ScriptTYpe = 'powershell'
ScriptText = $code
}
$result = Invoke-VMScript @sInvoke
$dummy, $out1 = $result.ScriptOutput -split '### Output ###'
$out1 = $out1.TrimStart("`n`r")
$report += $row | Add-Member -MemberType NoteProperty -Name 'DateTime' -Value ([DateTime]::Parse($out1)) -PassThru
}
}
$report | ft -auto