Hi,
I am unable to capture the passed and failed VM details in the output file. I am not getting any error but data is not getting captured
Please help.
$report = @()
$reportNotFound = @()
Import-Csv -Path $reportlocation1 -UseCulture -PipelineVariable row |
ForEach-Object -Process {
$sInvoke = @{
VM = $_.Name
GuestCredential = $Creds
ScriptTYpe = 'powershell'
ScriptText = $ScriptBlock
ErrorAction = 'Stop'
}
try{
Invoke-VMScript @sInvoke
"$($row.Name) DNS has been changed"
$report = $($row.Name)
}
catch{
Throw "DNS Failed for $($row.Name)"
$reportNotFound = $($row.Name)
}
$result
}
$report | Export-Excel -Path ".\DNS_Info.xlsx" -AutoFilter -AutoSize -BoldTopRow -FreezeTopRow -WorksheetName VM_Info
$reportNotFound | Export-Excel -Path ".\DNS_Info.xlsx" -AutoFilter -AutoSize -BoldTopRow -FreezeTopRow -WorksheetName VMs_Not_Found_Info
Those lines should be
$report += $($row.Name)
and
$reportNotFound += $($row.Name)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Those lines should be
$report += $($row.Name)
and
$reportNotFound += $($row.Name)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked. Thank you very much