Hi
so i modified this script :-
$objTemplate = @{
VM = ''
}
(Get-rCisTagCategory).Name | Sort-Object | ForEach-Object -Process {
$objTemplate.Add($_,'')
}
Get-rCisTagAssignment|
Group-Object -Property {$_.Entity.Name} |
ForEach-Object -Process {
$obj = $objTemplate.Clone()
$obj['VM'] = $_.Name
$_.Group | Group-Object -Property {$_.Tag.Category.Name} |
ForEach-Object -Process {
$cat = $_.Name
$vTag = $_.Group | Group-Object -Property {$_.Tag.Category.Name} |
ForEach-Object -Process {
$_.Group.Tag.Name
}
$obj[$cat] = (($vTag | Sort-Object) -join '|')
}
New-Object PSObject -Property $obj
} | Export-Csv -Path c:\temp\tagreport.csv -NoTypeInformation -UseCulture
I get the below error after a while:-
Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'VM' Key being added: 'VM'"
At line:8 char:4
+ $objTemplate.Add($_,'')
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
New-Object : Cannot process argument because the value of argument "name" is not valid. Change the value of the "name" argument and run the operation again.
At line:41 char:4
+ New-Object PSObject -Property $obj
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.NewObjectCommand
thanks in advance
mark