I have a PowerShell script that runs as Administrator, and another script it calls that needs to not run as Administrator. I've used Start-Process -FilePath "powershell.exe" -Verb runas
to elevate before, but how might I "unelevate" from a session already running as administrator?
I want to avoid third-party tools like psexec
that this post uses. Ideally looking for a build-in PS function or PSSnapin.
The specific process requiring this "unelevated" session is seeing drives mounted by an administrator. According to this article UAC is the likely culprit. The solution proposed was running the following:
New-ItemProperty -Path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Value 1 -PropertyType DWord
However, the drives still do not show up when Get-PSDrive
runs in an elevated session.