Working with remote registry
hello,
want to extract values [hkey_current_user\software\microsoft\office\common\userinfo] hive remote computers
they way accomplish retreive computerlist get-adcomputer cmdlet, atribute "managedby" (current owner of computer), retreive sid via get-aduser cmdlet , correct hive hku\sid\software\microsoft\office\common\userinfo
parts managed
* retreive computer names , managedby attributes
* retreive user sid
i didnt managed is
* write correct command retreiving registry keys using variables $computername , $usersid
something
$reg1 = reg query \\$computername\hku\$sid\software\microsoft\office\common\userinfo /v username
i think problem put variables reg query command line (so dont get "network path not found" )
thanks
if change regkey it's looking at, should work:
$reg1 = invoke-expression "reg query \\$($computername)\hku\$($sid)\software\microsoft\office\11.0\common\userinfo /s" $username=($reg1 | select-string -pattern '.+username.+?r.+\s+(.+)').matches | foreach{$_.groups[1].value} $username=($username.split("00",[system.stringsplitoptions]::removeemptyentries) | foreach{[char]([convert]::toint32($_,16))}) -join '' $userinitials=($reg1 | select-string -pattern '.+userinitials.+?r.+\s+(.+)').matches | foreach{$_.groups[1].value} $userinitials=($userinitials.split("00",[system.stringsplitoptions]::removeemptyentries) | foreach{[char]([convert]::toint32($_,16))}) -join '' $company=($reg1 | select-string -pattern '.+company.+?r.+\s+(.+)').matches | foreach{$_.groups[1].value} $company=($company.split("00",[system.stringsplitoptions]::removeemptyentries) | foreach{[char]([convert]::toint32($_,16))}) -join '' $userinitials $username $company i tidied little:
$reg1 = invoke-expression "reg query \\$($computername)\hku\$($sid)\software\microsoft\office\11.0\common\userinfo /s" filter convertfrom-hexa($hexstring){ ($hexstring.split("00",[system.stringsplitoptions]::removeemptyentries) | foreach{[char]([convert]::toint32($_,16))}) -join '' } $username=convertfrom-hexa (($reg1 | select-string -pattern '.+username.+?r.+\s+(.+)').matches | foreach{$_.groups[1].value}) $userinitials=convertfrom-hexa (($reg1 | select-string -pattern '.+userinitials.+?r.+\s+(.+)').matches | foreach{$_.groups[1].value}) $company=convertfrom-hexa (($reg1 | select-string -pattern '.+company.+?r.+\s+(.+)').matches | foreach{$_.groups[1].value}) $userinitials $username $company inspired carlsberg.
Windows Server > Windows PowerShell
Comments
Post a Comment