Advertisement
Guest User

Untitled

a guest
Aug 9th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module PSExcel, PoshRSJob
  2.  
  3. $Scriptblock = {
  4.     Param (
  5.         $Server
  6.     )
  7.     Try
  8.     {
  9.         $currentEAP = $ErrorActionPreference
  10.         $ErrorActionPreference = 'SilentlyContinue'
  11.         $props = @{ "Name" = $Server.VMName; "OS" = $Server.OSFullName }
  12.         if (Test-Connection -ComputerName $Server.VMName -Count 1 -Quiet) {
  13.             if (Test-WSMan -ComputerName $Server.VMName) {
  14.                 $props.PSVersion   = Invoke-Command -ComputerName $Server.VMName -ScriptBlock { $PSVersionTable.psversion.Major }
  15.             } else {
  16.                 $props.PSVersion   = 'WinRM Failure'
  17.             }
  18.         } else {
  19.             $props.PSVersion   = 'Ping Failure'
  20.         }
  21.         New-Object PSObject -Property $props
  22.     }
  23.     Catch {
  24.     }
  25. }
  26.  
  27. $ServerList = Import-Csv C:\winservers.csv
  28. $SyncArr = $ServerList | % { Start-RSJob -ScriptBlock $Scriptblock -ArgumentList $_ } | Wait-RSJob -ShowProgress |
  29.            Receive-RSJob | Select-Object "Name","OS","PSVersion"
  30. $SyncArr | Export-XLSX -AutoFit -Table -Path C:\psversions1.xlsx -Force
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement