Forum Discussion
Schulzi
Sep 07, 2020Brass Contributor
Powershell Scripts
Hello,
i have a little question using/creating scripts in Powershell.
In my Company we use RegEdit.exe a lot, so we want to automate some things, that's where the Problem starts...
We want to disable the OneDrive shortcut in the MS-Explorer - I know that the path to do that manually is "HKEY_USERS\[SID]_Classes\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}
I know how to get the SID via the cmdlet
"System.Security.Principal.NTAccount($env:Username).Translate([System.Security.Principal.SecurityIdentifier]).Value", so my question now:
Is there a way to get the [SID]_Classes via a cmdlet or format the "normal" [SID] using an cmdlet?
Greetings
Yannik
i have a little question using/creating scripts in Powershell.
In my Company we use RegEdit.exe a lot, so we want to automate some things, that's where the Problem starts...
We want to disable the OneDrive shortcut in the MS-Explorer - I know that the path to do that manually is "HKEY_USERS\[SID]_Classes\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}
I know how to get the SID via the cmdlet
"System.Security.Principal.NTAccount($env:Username).Translate([System.Security.Principal.SecurityIdentifier]).Value", so my question now:
Is there a way to get the [SID]_Classes via a cmdlet or format the "normal" [SID] using an cmdlet?
Greetings
Yannik
Hello Schulzi,
I am not aware of a cmdlet, but it’s quit easy to create the string you need by using string formatting. Take a look at this code:
$SID = (New-Object System.Security.Principal.NTAccount($env:Username)).Translate([System.Security.Principal.SecurityIdentifier]).Value $RegPath = '"HKEY_USERS"{0}_Classes-CLSID-018D5C66-4533-4307-9B53-224DE2ED1FE6"' -f $SID
More info is here:
https://devblogs.microsoft.com/scripting/understanding-powershell-and-basic-string-formatting/
Good luck!
Manfred de Laat
- Manfred101Iron Contributor
Hello Schulzi,
I am not aware of a cmdlet, but it’s quit easy to create the string you need by using string formatting. Take a look at this code:
$SID = (New-Object System.Security.Principal.NTAccount($env:Username)).Translate([System.Security.Principal.SecurityIdentifier]).Value $RegPath = '"HKEY_USERS"{0}_Classes-CLSID-018D5C66-4533-4307-9B53-224DE2ED1FE6"' -f $SID
More info is here:
https://devblogs.microsoft.com/scripting/understanding-powershell-and-basic-string-formatting/
Good luck!
Manfred de Laat
- SchulziBrass ContributorHello Manfred,
Thanks for the Quick Help, really helped me do my work.
Greetings
Yannik Schulz