Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

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

ParameterTypeDefaultDescription
Username (*)StringNoneAn existing Microsoft Windows local user account.
Password (*)StringNonePassword of specified user account.
DomainStringNonespecify the domain of the user account under which the new process is to be started.
ApplicationStringpowershell.exeApplication to be executed in the context of a different user.
ArgumentStringNoneAn optional argument to be passed to the application.
DetachSwitchFalseIf 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

Stars

98 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages