Powershell - 在远程计算机上搜索注册表项

时间:2016-08-04 17:29:03

标签: powershell

我有一个用户列表和他们登录的工作站。这是它的外观:

User1  Workstation1
User1  Workstation2
User2  Workstation3
User3  Workstation1
User4  Workstation6

我现在需要做的是搜索工作站的SID \ Printers \ Connections的注册表项HKEY_USERS。 Printers \ Connections有子文件夹,如下所示" ,, Server1,PrintQueue"

在此文件夹中有一个名为Server的值,该值为\ server或\ server.domain.com

到目前为止,我有以下内容:

  #set the workstation I am searching in
  $StrWorkstation = "workstation"
  #this is the value we are looking for
  $str2003Servers="*server*"
  #domain
  $domain = "test"
  #username
  $name="smithj"
  #get the SID
  $strSID = (Get-WmiObject -Class Win32_UserAccount -Filter "Domain = 'test'
  AND Name = 'smithj'").SID
  #this is where the key will be
  $StrKeyName="$strSID\Printers\Connections"

  $strRegType = [Microsoft.Win32.RegistryHive]::Users
  $strRegKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($strRegType,   
  $StrWorkstation)

  $strRegKey = $strRegKey.OpenSubKey($StrKeyName)

如何递归搜索 server 的Connections文件夹下的键或 server 的Connections键下每个键中的服务器值?

0 个答案:

没有答案