Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

PowerShell Registry Access failing

$
0
0

I've been using the very helpful PSRemoteRegistry module to gather information from multiple servers on my network. However, I've found that it throws an error when requesting Registry information if the server name includes a hyphen.

This code:

$Date = Get-RegValue -ComputerName $Computer.Name -Key "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install" -Value LastSuccessTime

works just fine if $Computer.Name contains something like "Server1" but it fails when it contains something like "SQL-Server". It appears that it is breaking the name into two parts.

The failing code in the function in Get-RegValue is:

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]$Hive,$c)

The error is:

Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.

"

At...


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>