HOW TO USE POWERSHELL AS AN ADMIN IN MacOS

Iron Contributor

Howdy Folks,

 

I have a simple query, being fond of using the Powershell in Windows Machines where I usually run the commands or install the modules and to do so we need to run the Windows PowerShell as an administrator!! But the same option is not available in MacOS.

 

Though I know how to use the Powershell for the current user in MacOS - https://dmitrysotnikov.wordpress.com/2016/08/19/run-powershell-on-mac-os-x/ (Steps to install the Powershell in MacOS)

 

Customize the Powershell in Terminal Application (https://info.sapien.com/index.php/quickguides/setting-up-powershell-on-your-mac) also done!

 

But running a Powershell as an admin is not happening in MacOS. Please help it out in this.

 

1 Reply

@Mitul Sinha 

 

You need to run pwsh under the login and environment of an Admin user (a user that is a member of the "admin" UNIX group in OSX).

 

To verify if a user account is member use the terminal command

   id username

and check if the Group "admin" is listed (usually it has the numerical ID 80)

 

Then switch to that user using the command

    sudo su - username

*This command will prompt you for your CURRENT user's password if you are allowed to use sudo

 

If you are not allowed to use sudo, use

    su - username

directly, this will prompt for the password of the user you want to switch to.

 

Note that "sudo su  - root" is the only way to switch to the root account (superuser admin) on OSX.

 

Once you switched to that user context, launch powershell

    pwsh

 

and install any module/package for -Scope AllUsers

 

cheers,