I want to get empty space of every drive of server with powershell using C#
this is the powershell script which works fine
Get-PSDrive |Format-Table
what I want is to take output of this script and show it on UI
What I tried till now.
string scriptToCheckDBServerMemorySpace = "Get-PSDrive |Format-Table";
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddScript(scriptToCheckDBServerMemorySpace);
Collection<PSObject> PSObject = PowerShellInstance.Invoke();
foreach (PSObject PSOutputItem in PSObject)
{
if (PSOutputItem != null)
{
//TxtFirstStepResult.Text = PSOutputItem.BaseObject.ToString() + "\n";
}
}
if (PowerShellInstance.Streams.Error.Count > 0)
{
TxtFirstStepResult.Text = PowerShellInstance.Streams.Error.ToString() + "\n";
}
Console.ReadKey();
}
the question is how to get output of this powershell script and show it on windows form application. I am not able to figure out how to convert this PS object and convert it to readable format.
please redirect me to the right direction.