Skip to content

This module allows you to run a process (defaulting to PowerShell) as a different user by providing a known username and password. By default, the standard output (stdout), standard error (stderr), and standard input (stdin) are attached to the current console of the caller.

License

Notifications You must be signed in to change notification settings

PhrozenIO/PowerRunAs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PowerRunAs

This module allows you to run a process (defaulting to PowerShell) as a different user by providing a known username and password. By default, the standard output (stdout), standard error (stderr), and standard input (stdin) are attached to the current console of the caller.

This module can also be used as standalone script.

Installation

As a Module

Install-Module -Name PowerRunAs
Import-Module -Name PowerRunAs

As a Script

IEX (Get-Content .\PowerRunAs.psm1 -Raw)

Or

IEX (New-Object Net.WebClient).DownloadString('<protocol>://<host>:<port>/<uri>/PowerRunAs.psm1')

Or Invoke-🧠

Usage

Parameter Type Default Description
Username (*) String None An existing Microsoft Windows local user account.
Password (*) String None Password of specified user account.
Domain String None specify the domain of the user account under which the new process is to be started.
Application String powershell.exe Application to be executed in the context of a different user.
Argument String None An optional argument to be passed to the application.
Detach Switch False If present, stdout, stdin, and stderr will not be connected to the current caller's console. The process will run in a detached state and will be visible.

* = Mandatory Options

Example

Example

net user darkcodersc mypassword /add
# Launch a new instance of PowerShell as the user darkcodersc in the caller's console (attached).
Invoke-RunAs -Username "darkcodersc" -Password "mypassword"

# Launch a visible notepad as the user darkcodersc (dettached)
Invoke-RunAs -Username "darkcodersc" -Password "mypassword" -Application "notepad.exe" -Detach

About

This module allows you to run a process (defaulting to PowerShell) as a different user by providing a known username and password. By default, the standard output (stdout), standard error (stderr), and standard input (stdin) are attached to the current console of the caller.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published