Hi,
Need help with adding the name of the dept head for the below, how can I achieve this ?
Example : get-vm | select @{N="Folder";E={$_.Folder.Name}}, Name
Current Output :
Folder VMName
Marketing App1
HR App2
Learning App3
Sales App4
But I would like to add one more column with Department head
Steve for Marketing and Sales Folder
Tom for HR
Lisa for Learning
Department_Head Folder VMName
Steve Marketing App1
Tom HR App2
Lisa Learning App3
Steve Sales App4
Please help!!!
If you have the information in a table, you could use a hash table as a lookup table.
Something like this
Dept,Head
Marketing,Steve
HR,Tom
Learning,Lisa
Sales,Stev
'@
$deptTab = @{}
ConvertFrom-Csv -InputObject $dept -UseCulture |
ForEach-Object -Process {
$deptTab.Add($_.Dept,$_.Head)
}
Get-VM |
select Name,
@{N="Folder";E={$_.Folder.Name}},
@{N='DeptHead';E={$deptTab[$_.Folder.Name]}}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
From where do you get the Department Head?
Is that a separate file?
How do decide which Department Head goes to which VM?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I am not sure, how can I do the mapping, I want to do the department head`s name mapping based on the Folder name.
If you have the information in a table, you could use a hash table as a lookup table.
Something like this
Dept,Head
Marketing,Steve
HR,Tom
Learning,Lisa
Sales,Stev
'@
$deptTab = @{}
ConvertFrom-Csv -InputObject $dept -UseCulture |
ForEach-Object -Process {
$deptTab.Add($_.Dept,$_.Head)
}
Get-VM |
select Name,
@{N="Folder";E={$_.Folder.Name}},
@{N='DeptHead';E={$deptTab[$_.Folder.Name]}}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
BullsEye, that worked.....Thanks a lot LucD