Skip to main content

How do I run Powershell as Another User?

Overview

Does your Powershell command require another user in your pipeline? Do you require a specific user with a role with valid permissions? There are several reasons to need to authenticate as a different user.

Here is how you can run as a different user:

$credential = Get-Credential # You will be prompted for the username and password here.Enter-PSSession -ComputerName localhost -Credential $credential# Run your PowerShell commands here.Exit-PSSession

Additional Resources

See information on our Windows Orb:
https://circleci.com/developer/orbs/orb/circleci/windows

Using the Windows Environment:

Using your own hardware? See more information on Windows Machine Runners:

Did this answer your question?