因此,我尝试使用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设置为enabled。我设置了它,然后将更新后的策略下拉到相同的结果。还有什么东西可能会影响我的连接呢?
发布于 2013-08-26 00:27:38
我建议使用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发布于 2017-09-14 00:30:28
我通过powershell使用了以下命令,以管理员身份运行:
wmic /user:jc1_admin /node:pc00202 os get "SerialNumber"https://stackoverflow.com/questions/17976638
复制相似问题