PowerShell: Checking whether you have admin rights

If you create a PowerShell script that should perform actions that require administrator rights, you can also check this in code. This allows you to make sure that your script can be executed successfully. The easiest way is with a Requires statement. 🎬 I also created a video on this topic. Requiring admin rights with a Requires statement 1 #Requires -RunAsAdministrator This line can be inserted at any point in the PowerShell code. I would always place it fairly near the top of the script so it is easy to see. But the position technically does not matter. So if the #Requires statement is in the code, it is evaluated before the rest of the code is executed. Depending on whether administrator rights are present or not, an error is returned. ...

2024-02-20 · 4 min · Andreas Dieckmann

Finding localized Security Identifier names in PowerShell

Security Identifiers are used to identify specific security principals or groups in Windows. Unfortunately, their names are localized, so for example they differ between a German and an English system. For example, the built-in Administrators group is called BUILTIN\ADMINISTRATORS in English and VORDEFINIERT\Administratoren in German. Or the English NT AUTHORITY\SYSTEM becomes NT-AUTORITÄT\SYSTEM on a German system. I think that is really weird. Suddenly a space is replaced by a hyphen. Well, whatever. ...

2024-01-17 · 2 min · Andreas Dieckmann