How to elevate an already running session within its own code
I'm writting a PowerShell script that configures some things in Active Directory. I need to run it as a specific user in order to get the right permissions for the process, currently i'm running the .ps1 file through a .bat file, so I can choose "run as a different user" or "run as administrator". What I'm tryng to achieve is that inside the script I will ask the user for the right credentials, and then elevate the session to run with the inputed user creds. I've tried using this within my code: Start-Process powershell.exe -Credential "TestDomain\Me" But it just opens an empty PS Session