carbonbase
asked on
Using split in a hashtable
I found the following code to output some information from vCenter:
The problem I am having is that the output of "Guest" returns output in the following format:
MyVirtualMachine:Microsoft Windows Server 2008 (32 bit)
What I would like is not to output the "MyVirtualMachine:" bit. I've used the split command before to do something like this but I can't get it to work inside a hash table. Also I think I need to convert the "Guest" value to a string before I can use split.
I would appreciate advice on how to do this. Thanks.
Get-VM |
Select Name,
@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="UsedSpaceGB";E={[math]::Round($_.UsedSpaceGB,1)}},
@{N="ProvisionedSpaceGB";E={[math]::Round($_.ProvisionedSpaceGB,1)}},
@{N="Guest";E=($_.Guest}},
@{N="PowerState";E={$_.PowerState}},
@{N="Notes";E={$_.Notes}} |
Export-Csv C:\Temp\report.csv -NoTypeInformation -UseCulture
The problem I am having is that the output of "Guest" returns output in the following format:
MyVirtualMachine:Microsoft
What I would like is not to output the "MyVirtualMachine:" bit. I've used the split command before to do something like this but I can't get it to work inside a hash table. Also I think I need to convert the "Guest" value to a string before I can use split.
I would appreciate advice on how to do this. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER