This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Try { | |
$CimSession = New-CimSession -ComputerName $Computer -ErrorAction Stop | |
} | |
Catch { | |
Clear-Variable EV -ErrorAction SilentlyContinue | |
$CimSession = New-CimSession -ComputerName $Computer -SessionOption (New-CimSessionOption -Protocol Dcom) -ErrorAction SilentlyContinue -ErrorVariable EV | |
} | |
If ($EV) | |
{ Write-Warning "$($Computer): Unable to connect because ""$($Error[0])""" | |
Continue | |
} | |
Try { | |
$Disks = Get-CimInstance Win32_LogicalDisk -Filter "DriveType = 3" -CimSession $CimSession -ErrorAction Stop | |
} | |
Catch { | |
Write-Warning "$($Computer): Unable to retrieve disk information because ""$($Error[0])""" | |
Continue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment