I am building a GUI to get-GPResulantSetOfPolicy
I want to open the GUI as myself but run the following command as a User Account that is in the Domain Admins group.
Here is my cmd for getting the Domain Admin Credentials: This will prompt before launching the gui
$Cred=Get-Credential-Message'Enter your Credentials'
Here is my cmd for getting the GPO Report:
Get-GPResultantSetOfPolicy-Computer$textfield.Text -User$textfield1.Text -ReportTypeHTML-PathC:\GPOreport\RSOP.HTML
My problem is that the GUI is still running the Get-GPResulantSetOfPolicy under my credentials and I am getting Access Denied.
I know I can do the Start-Process Powershell.exe -Credential $Cred -NoNewWindow -Arguementlist "Start-Process powershell.exe -verb runAs"
But this opens a whole new Powershell window under the domain admin credentials and not my GUI Tool that I made.
So my question in short is how do I open my GUI as me, but run that Powershell CMD as the Domain Admin account?
Thanks,