626 views

Description

The error 'The RPC server is unavailable" is deemed non-terminating by Powershell.

If power-shell command finds an error, it stops process at that point and throws exception which is handled in the code. This is called "terminating errors".

Default behaviors is "Continue" which is called, "non-terminating" and does not throw exception. 

Steps to Reproduce

 

Example of the MSSQL Probe Script Snippet with workaround:

function getRegistryProvider() { 
if ($cred) {
$reg = Get-WmiObject -List -Namespace root\default -ComputerName $ip -Credential $cred -ErrorAction SilentlyContinue | Where-Object {$_.Name -eq "StdRegProv"}
} else {
$reg = Get-WmiObject -List -Namespace root\default -ComputerName $ip -ErrorAction Stop | Where-Object {$_.Name -eq "StdRegProv"}
}

return $reg
}

Error:

<error> 
Get-WmiObject : Could not get objects from namespace root\default. The RPCserver is unavailable. (Exception from HRESULT: 0x800706BA)At C:\Users\ServiceNowDiscovery\AppData\Local\Temp\sqlinfo.9212395334480311389.PS1:306 char:16+ $reg = Get-WmiObject -List -Namespace root\default -ComputerName $ip-Cr ...+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (:) [Get-WmiObject], COMException+ FullyQualifiedErrorId : INVALID_NAMESPACE_IDENTIFIER,Microsoft.PowerShell.Commands.GetWmiObjectCommandGet-WmiObject : Could not get objects from namespace root\default. The RPCserver is unavailable. (Exception from HRESULT: 0x800706BA)At C:\Users\ServiceNowDiscovery\AppData\Local\Temp\sqlinfo.9212395334480311389.PS1:306 char:16+ $reg = Get-WmiObject -List -Namespace root\default -ComputerName $ip-Cr ...+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (:) [Get-WmiObject], COMException+ FullyQualifiedErrorId : INVALID_NAMESPACE_IDENTIFIER,Microsoft.PowerShell.Commands.GetWmiObjectCommandGet-WmiObject : Could not get objects from namespace root\default. The RPCserver is unavailable. (Exception from HRESULT: 0x800706BA)At C:\Users\ServiceNowDiscovery\AppData\Local\Temp\sqlinfo.9212395334480311389.PS1:306 char:16+ $reg = Get-WmiObject -List -Namespace root\default -ComputerName $ip-Cr ...+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound: (:) [Get-WmiObject], COMException+ FullyQualifiedErrorId : INVALID_NAMESPACE_IDENTIFIER,Microsoft.PowerShell.Commands.GetWmiObjectCommand
</error>

Workaround

Setting an ErrorAction with Stop forces the exception to occur in the try/catch, which properly handles the error and continues the script.

Add the following line at the start of the discovery_probe_parameter.do?sys_id%3Dde07453f0a0a0b7800d06b79122bbc5b script:

$ErrorActionPreference = 'Stop'

If you are able to upgrade, review the Fixed In field to determine the versions that have a permanent fix.

 


Related Problem: PRB752896

Seen In

Helsinki Patch 8

Fixed In

Istanbul Patch 9
Jakarta Patch 2
Kingston

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-03-12 16:10:08
Published:2017-09-11