Does anyone know how to catch this specific error using try catch?
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At C:\Install\powershell\Retrieve.ps1:66 char:15
- $shares = gwmi <<<< Win32_Share -computername $fileServer -filter ‘type=0’
- CategoryInfo : NotSpecified: (
[Get-WmiObject], UnauthorizedAccessException - FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
- CategoryInfo : NotSpecified: (