|Apologies if this has been answered before.
I have a C# program that calls various PowerShell scripts as it runs. If I run the program as an administrator, it doesn't seem to pass on the elevated rights to the runspaces used for executing the scripts.
Is there any way to do this? The code I am using to run the scripts is below:
string mScriptPath = "Project.Resources." + mScriptName + ".ps1";
Assembly _assembly = Assembly.GetExecutingAssembly();
StreamReader _psStreamReader = new StreamReader(_assembly.GetManifestResourceStream(mScriptPath));
Runspace runspace = RunspaceFactory.CreateRunspace();
string powerShell = _psStreamReader.ReadToEnd();
var shell = PowerShell.Create();
Any help would be appreciated