Quick Tip: Run PowerShell elevated as a domain admin

If, like any sane sysadmin, you adhere to best practice and your own user account isn’t a domain admin, you’re likely to be running certain operations as a domain admin.

I’ve used batch files to run CMD, MMC, and other applications as a domain admin account in the past. To run PowerShell, I had to use a slightly different method.

1. Create a PowerShell script that contains the following, and save it somewhere:
Start-Process powershell.exe -Credential "domainadministrator"

2. Create a shortcut on your desktop or similar, with the following path:
%SystemRoot%system32WindowsPowerShellv1.0powershell.exe -File C:pathtoscriptRun-PowerShell-Elevated.ps1

3. Optionally, set the shortcut icon to one of the ones contained in the PowerShell exe. I used the UAC one.

To test that it worked, run the script, authenticate, and then do the following:
Set-Location env:

You should see that the username matches the one you started the process as.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s