The PowerShell command provided below will enumerate all local accounts that belong to the Administrator group or possess administrative privileges on the system.
Here is the PowerShell code to execute:
Get-CimInstance Win32_GroupUser | Where-Object {$_.GroupComponent.Name -eq "Administrators"} | Select-Object -ExpandProperty PartComponent | Select-Object -Property Name
Example Output:
There are other ways to list user accounts with administrator privileges on a Windows System.
On a server OS or other OS that supports Microsoft Management Console command will also show the list of users with admin rights, press "windows key + r" and when run box appears type: "lusrmgr.msc" or simply open a command prompt and type the command: "lusrmgr.msc", if the command is supported it will show a window where you can check the list of users with admin access.
The MMC is beneficial because it features a graphical interface, but using scripts proves to be advantageous when managing remote computers or servers. Scripts can provide greater flexibility and efficiency in such scenarios. Choice is yours.
Keep It Simple SysAdmin (KISS method) still a best practice.
Memento Mori, Remember Death. No one is exempted. Pray always and be filled with humility.
Here is the PowerShell code to execute:
Get-CimInstance Win32_GroupUser | Where-Object {$_.GroupComponent.Name -eq "Administrators"} | Select-Object -ExpandProperty PartComponent | Select-Object -Property Name
Example Output:
There are other ways to list user accounts with administrator privileges on a Windows System.
On a server OS or other OS that supports Microsoft Management Console command will also show the list of users with admin rights, press "windows key + r" and when run box appears type: "lusrmgr.msc" or simply open a command prompt and type the command: "lusrmgr.msc", if the command is supported it will show a window where you can check the list of users with admin access.
The MMC is beneficial because it features a graphical interface, but using scripts proves to be advantageous when managing remote computers or servers. Scripts can provide greater flexibility and efficiency in such scenarios. Choice is yours.
Keep It Simple SysAdmin (KISS method) still a best practice.
Memento Mori, Remember Death. No one is exempted. Pray always and be filled with humility.
Comments
Post a Comment