I work in a multiple AD forest environment and quite often have to support clients who have manually mapped drives under their local profiles in addition to their policy mapped ones
When our remote control software fails on machine for some reason and the client is in need of a profile reset it is quite handy to have information about the clients manually mapped drives beforehand so they can be re-mapped for them afterwards.
It is quite easy to query the registry using psexec after determining the logged on users SID, but I am stuck as to which way to proceed after that for individual drive letters. # Required Info $domvar = read-host "Domain to Query: "
$usrvar = read-host "UID: "
$pcvar = read-host "PC Name: " # Get users domain SID $strusr = new-object system.security.principal.ntaccount ($domvar, $usrvar)
$strsid = $strusr.translate([system.security.principal.securityidentifier]) # Pass values and use PSEXEC to query remote Current User settings psexec \\$pcvar reg query hku\$strsid\network
from here I am a bit stuck as to the best way to filter out the registry values nice and cleanly however, each drive will be listed as per its drive letter as a subkey, and under each subkey the 'RemotePath' string value specifies the drives UNC path.
Is there an easier way to do this (maybe even without PSEXEC)
Am I going about this the wrong way altogether?