I'm attempting to retrieve contents of the query below. However, one of the fields - Paths - is of type System.Management.ManagementBaseObject. What is the proper way to do this in C#? I'm including PowerShell code below to demonstrate how to do the same in that language. The value I'm trying to retrieve is actually part of Paths - Paths.ScsiAddress.Lun.
Appreciate all the help.
query = new ObjectQuery("Select Active, LunSize, Paths FROM ONTAPDSM_LUNINFO");
CompSys = new ManagementObjectSearcher(oMs, query);
CompSysList = CompSys.Get();
foreach (ManagementObject MO in CompSysList)
{
object col1 = MO["Active"] != null ? MO["Active"].ToString() : null;
object col2 = MO["LunSize"] != null ? MO["LunSize"].ToString() : null;
object col3 = MO["Paths"] != null ? MO["Paths"].ToString() : null;
}
PowerShell:
gwmi -Namespace root/wmi -Query "Select Active, LunSize, Paths FROM ONTAPDSM_LUNINFO" | Select
Active, LunSize, @{N="ID";E={$_.Paths.ScsiAddress.Lun}}
Active LunSize ID
------ ------- --
True 16113323520 {0, 0, 0, 0}
True 141738024960 {1, 1, 1, 1}
True 74093322240 {2, 2, 2, 2}
True 5371107840 {3, 3, 3, 3}
True 1077511680 {4, 4, 4, 4}
No comments:
Post a Comment