Skip to content

Instantly share code, notes, and snippets.

@martin9700
Created February 26, 2014 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martin9700/9235922 to your computer and use it in GitHub Desktop.
Save martin9700/9235922 to your computer and use it in GitHub Desktop.
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