Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

RunAS within Script

$
0
0

Hello,

I'm not sure what I'm trying to do, is even possible...

I want to start my script with powershell console using non administrative credentials. Once the script has started, it prompts for administrative credentials then it start the script. Script is in a shared folder...

I found this

Powershell
if(!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")){Start-Processpowershell.exe"-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""-VerbRunAs;exit}

I put this in line 1 of the script, it does work, but the new powershell windows, closes right after. I would like it to pop the menu I created within the script.

Thanks, I'm open to any other suggestion also.


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>