Untitled

 avatar
unknown
plain_text
a year ago
757 B
5
Indexable
$computer = "computername"
$user = (Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer).UserName.split('\')[-1]
$sid = (Get-ADUser $user).SID.Value
Invoke-Command -ComputerName $computer -ScriptBlock {
    Set-Location Registry::HKEY_USERS
    New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS
    Set-Location HKU:
    $drives = Get-ChildItem -Path Microsoft.PowerShell.Core\Registry::HKEY_USERS\$($args[0])\Network -Recurse
    $driveresults = foreach ($d in $drives) {
        $q = "Microsoft.PowerShell.Core\Registry::HKEY_USERS\$($args[0])\Network\" + $d.PSChildName
        Get-ItemProperty -Path $q
    }
    $driveresults | Format-Table PSChildName, RemotePath -AutoSize -HideTableHeaders
} -ArgumentList $sid
Editor is loading...
Leave a Comment