I’m pretty new with PowerShell but have done some online training to self teach. I’m in a field support role and I am trying to make a tool to help re-create windows local profiles on a machine. I’ve written my script and tested it locally, however I want to be able to specify a remote computer name to be the target. It does not appear test-path or rename-item support the -computername parameter. Unfortunately psremoting is not enabled (I’ve began working on putting together something to present to the engineering dept management to see if we can enable via gpo, but I wouldn’t count on it anytime soon). Is there another way to use those commands in the meantime?
The gist of my script is to get the SID from AD for a specified username, then check the target pc (currently local machine, but hopefully soon a remote one) to see if that user exists on the machine, once that is confirmed it will then check the registry to see if that user has already had an old$Num.SID created in the past, if so it’ll increment $Num to the next number and check again. Once a valid number is found it will rename the registry key and directory path for that user to old$Num.xxxx
Here is examples of my code:
Checking to see if the userprofile exists on the machine before trying to rename it.
Test-Path -Path "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList$SID"
Renaming the registry Key
Rename-Item -Path "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList$SID" -NewName "old$Num.$SID" -Force
Thanks!
submitted by /u/jabrake88
[link] [comments]
The post Managing Remote Registry Help appeared first on How to Code .NET.