Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module PSExcel, PoshRSJob
- $Scriptblock = {
- Param (
- $Server
- )
- Try
- {
- $currentEAP = $ErrorActionPreference
- $ErrorActionPreference = 'SilentlyContinue'
- $props = @{ "Name" = $Server.VMName; "OS" = $Server.OSFullName }
- if (Test-Connection -ComputerName $Server.VMName -Count 1 -Quiet) {
- if (Test-WSMan -ComputerName $Server.VMName) {
- $props.PSVersion = Invoke-Command -ComputerName $Server.VMName -ScriptBlock { $PSVersionTable.psversion.Major }
- } else {
- $props.PSVersion = 'WinRM Failure'
- }
- } else {
- $props.PSVersion = 'Ping Failure'
- }
- New-Object PSObject -Property $props
- }
- Catch {
- }
- }
- $ServerList = Import-Csv C:\winservers.csv
- $SyncArr = $ServerList | % { Start-RSJob -ScriptBlock $Scriptblock -ArgumentList $_ } | Wait-RSJob -ShowProgress |
- Receive-RSJob | Select-Object "Name","OS","PSVersion"
- $SyncArr | Export-XLSX -AutoFit -Table -Path C:\psversions1.xlsx -Force
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement