Extract out data from an array or variable

I’ve been trying to get ChatGPT to write this but it never seems to work the way I want. I have a variable that has this data inside of it.



Caption                    : 
Description                : 
ElementName                : 
CommunicationStatus        : 
DetailedStatus             : 
HealthState                : 
InstallDate                : 
Name                       : Main System Chassis
OperatingStatus            : 
OperationalStatus          : 
PrimaryStatus              : 
Status                     : 
StatusDescriptions         : 
CanBeFRUed                 : False
CreationClassName          : DCIM_Chassis
ManufactureDate            : 7/8/2022 5:00:00 PM
Manufacturer               : Dell Inc.
Model                      : Precision 7770
OtherIdentifyingInfo       : 
PartNumber                 : N/A
PoweredOn                  : 
SerialNumber               : N/A
SKU                        : N/A
Tag                        : CXXGTQ3
UserTracking               : 
VendorEquipmentType        : 
Version                    : 
Depth                      : 
Height                     : 
HotSwappable               : 
OtherPackageType           : 
PackageType                : 3
Removable                  : 
RemovalConditions          : 2
Replaceable                : 
VendorCompatibilityStrings : 
Weight                     : 
Width                      : 
AudibleAlarm               : 
BreachDescription          : Chassis cover was opened
CableManagementStrategy    : 
IsLocked                   : 
LockPresent                : False
SecurityBreach             : 5
ServiceDescriptions        : 
ServicePhilosophy          : 
VisibleAlarm               : 
ChassisPackageType         : 10
ChassisTypeDescription     : 
ChassisTypes               : 
CurrentRequiredOrProduced  : 
HeatGeneration             : 
InputCurrentType           : 
InputVoltage               : 
MultipleSystemSupport      : 
NumberOfPowerCords         : 
OtherInputCurrentType      : 
RackMountable              : 
TypeDescriptions           : 
FirstPowerOnDate           : 1/24/2023 4:00:00 PM
PropertyOwnershipTag       : 
PSComputerName             : 

Caption                    : 
Description                : 
ElementName                : Docking Station
CommunicationStatus        : 
DetailedStatus             : 
HealthState                : 
InstallDate                : 
Name                       : WD22TB4
OperatingStatus            : 
OperationalStatus          : 
PrimaryStatus              : 
Status                     : 
StatusDescriptions         : 
CanBeFRUed                 : 
CreationClassName          : DCIM_DockingStation
ManufactureDate            : 
Manufacturer               : Dell Inc.
Model                      : CABLE_ID_130W_TBT4
OtherIdentifyingInfo       : 
PartNumber                 : 
PoweredOn                  : 
SerialNumber               : 218-84-125-1-19-39-11-0
SKU                        : 
Tag                        : 27YGHV3
UserTracking               : 
VendorEquipmentType        : 
Version                    : 01.00.25.01
Depth                      : 
Height                     : 
HotSwappable               : 
OtherPackageType           : 
PackageType                : 1
Removable                  : 
RemovalConditions          : 2
Replaceable                : 
VendorCompatibilityStrings : {DCIM:Docking Station}
Weight                     : 
Width                      : 
AudibleAlarm               : 
BreachDescription          : 
CableManagementStrategy    : 
IsLocked                   : 
LockPresent                : 
SecurityBreach             : 
ServiceDescriptions        : 
ServicePhilosophy          : 
VisibleAlarm               : 
ChassisPackageType         : 12
ChassisTypeDescription     : Docking Station
ChassisTypes               : 
CurrentRequiredOrProduced  : 
HeatGeneration             : 
InputCurrentType           : 
InputVoltage               : 
MultipleSystemSupport      : 
NumberOfPowerCords         : 
OtherInputCurrentType      : 
RackMountable              : 
TypeDescriptions           : 
FirstPowerOnDate           : 
PropertyOwnershipTag       : 
PSComputerName             : 



There are 2 lines that begin with the word VERSION. I only want the line that has data next to it.

Version : 01.00.25.01

and I really only want that number After the colon. 01.00.25.01

Now, I have this working perfectly but using .TXT files. i.e. output-file and then get-content but I wanted to make it very clean and use only variables and/or an array. It has turned out to be very tricky.

Any help would be nice.

How about sharing the code you used to populate the variable? :man_shrugging:t3:

You need Dell Command Monitor installed for this command to work.

$GetData = Get-CimInstance -Namespace root/DCIM/SYSMAN -ClassName DCIM_Chassis

if you don’t have Dell Command Monitor installed it won’t return anything, that is why I posted what it actually finds in my original post.

$GetData.Version

:man_shrugging:t3:

I could of sworn I tried that and it failed. I must have had it in the wrong location. :face_with_spiral_eyes:

Question. If there are 2 VERSIONS how does $GetData.Version return only the VERSION with a value? and not two lines.

It pretty sure did. But since the one version is an empty value you don’t see it. Your output looks like you’ve got two objects back. You can verify this by running

$GetData.count

And you can access the individual elements of the array by their index

$GetData[0]

or

$GetData[1]

And you can access the version property of one particular element by using its index and property name:

$GetData[0].Version

or

$GetData[1].Version