First, this is how my csv look like
ip,Component,User,Pwd,type
172.22.0.67,desktopstudio,Administrator,Activlan2015,xendesktop
10.10.10.0,controller,Administrator,Activlan2015,xendesktop
172.22.0.67,storefront,Administrator,Activlan2015,xendesktop
10.10.10.0,desktopdirector,Administrator,Activlan2015,xendesktop
172.22.0.2,licenseserver,Administrator,Activlan2015,xenapp
And this is my script :
$Csv = "C:\springfield\Citrix\CitrixComposants.csv"
$data = Import-Csv $Csv
Foreach ($Server in $Data)
{
Import-module C:\springfield\Citrix\CitrixDeploymentActivlanModule.ps1
Deploy-Citrix -component $Server.component -ip $Server.ip -username $Server.user -pwd $Server.Pwd -type $Server.type
}
When i execute this code, this is how function take parameters :
Deploy-Citrix -component desktopstudio -ip 172.22.0.67 ......
Deploy-Citrix -component controller -ip 10.10.10.0 ......
Deploy-Citrix -component storefront -ip 172.22.0.67 ......
Deploy-Citrix -component desktopdirector -ip 10.10.10.0 ......
Deploy-Citrix -component licenseserver -ip 172.22.0.2 ......
I would like to combine "Component" value, when the ip is the same.
In this CSV, we have three unique ip 172.22.0.67, 10.10.10.0 and 172.22.0.2, and i want to combine "Component" value for each unique IP, to execute my Foreach loop 3 time only :
Deploy-Citrix -component desktopstudio,storefront -ip 172.22.0.67 ......
Deploy-Citrix -component controller,desktopdirector -ip 10.10.10.0 ......
Deploy-Citrix -component licenseserver -ip 172.22.0.2 ......
My function can already take array of string :
Function Deploy-Citrix {
[cmdletBinding(SupportsShouldProcess=$True)]
Param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string[]]$component,
....
)
How can i do that?
Thank you