I have a snippet that executes a PowerShell script
using (var ps = PowerShell.Create())
{
ps.AddScript("function Test() { return Get-Disk -Number 0 } ");
ps.Invoke();
ps.AddCommand("Test");
var results = ps.Invoke();
var disk = results.First();
MyDisk myDisk = // do something to convert disk to myDisk
}
Debuggin, it get his inside disk
:
How I'm supposed to deal with this object (CimObject
)? I would like to get the values from the "Name" and "Number" properties.
Just to clarify, the object I'm trying to deal is the same type as this (run into PowerShell as admin)
PS C:\windows\system32> $disk = Get-Disk -Number 0
PS C:\windows\system32> $disk.GetType();
How do I interact with this?
Thank you!