Jump to content

Run powershell on user site elevated user.


Cezar

Recommended Posts

Deze script werkt als het gerunt is van een user account maar niet vanuit pulseway.

 

$password = ConvertTo-SecureString "your_password" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential("your_username", $password)

$scriptBlock = {
    Start-Process powershell -Verb RunAs
    Write-Host "Running with elevated privileges!"
}

$encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($scriptBlock))
Start-Process powershell.exe -ArgumentList "-NoProfile -EncodedCommand $encodedCommand" -Credential $credentials
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...