2 Replies Latest reply on Jul 1, 2020 11:22 PM by ganapa2000

    Unable to capture VM Information

    ganapa2000 Hot Shot



      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'



              Invoke-VMScript @sInvoke

              "$($row.Name) DNS has been changed"

              $report = $($row.Name)



              Throw "DNS Failed for $($row.Name)"

              $reportNotFound = $($row.Name)




      $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