所以我正在尝试使用http://gallery.technet.microsoft.com/scriptcenter/Get-product-keys-of-local-83b4ce97#content中的PS脚本远程从我的域中提取Windows产品密钥。但是,当它命中主机时,它会返回Exception calling “OpenRemoteBaseKey” with “2″ argument(s): “The network path was not found”
而不是产品密钥。还应该指出,这在当地有效。在对脚本的内部进行探讨之后,似乎违规的行是
$remoteReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Computer)
研究(因为我对PoSH完全不熟悉)表明当远程注册表访问不起作用时会抛出此类错误。尝试通过regedit挂钩我的测试目标上的注册表,这表明我需要在组策略中设置为Windows Firewall: Allow inbound remote administration exception
。我设置它,然后将更新的策略下拉到相同的结果。还有什么其他东西可能妨碍我的联系?
答案 0 :(得分:0)
我建议使用PSRemoting而不是使用远程注册表。假设已经设置好了,您所要做的就是:
$computers = @('localhost')#list of computers
#unless you are currently logged in as a domain admin
# you will need to provide credentials
$cred = Get-Credential domain\administrator
Invoke-Command -Credential $cred -ComputerName $computers -ScriptBlock {
function Get-ProductKey{
#from http://gallery.technet.microsoft.com/scriptcenter/Get-product-keys-of-local-83b4ce97
}
get-ProductKey
}| ft Computername,OSDescription,OSVersion,ProductKey
这将打印出以下输出:
Computername OSDescription OSVersion ProductKey
------------ ------------- --------- ----------
%name% Microsoft Windows 8 Pro 6.2.9200 XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
答案 1 :(得分:0)
我在powershell中使用了以下命令,以管理员身份运行它:
wmic /user:jc1_admin /node:pc00202 os get "SerialNumber"