The below method launches a powershell script and executes it
private static void LaunchPowershell()
{
string exeDir = "H:\\aws-newAPIKey";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = @"C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe";
startInfo.Arguments = exeDir + "\\newApiKey_wh1.ps1";
startInfo.WorkingDirectory = exeDir;
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
This results in the following output in the command line:
CreatedDate : 1/3/2018 7:20:16 PM
CustomerId :
Description : This is api key for customer
Enabled : True
Id : qraj84yl5h
LastUpdatedDate : 1/3/2018 7:20:16 PM
Name : newAPIKey7
StageKeys : {}
Value : 2LBtWluNX1XbgtDG0SPY1IQgnVDkZTwzmgY3kd60
What I want to do is to obtain the Value of the API key created in C#. Is there a way to do this without using System.Management.Autmomation library?