Nishant Joshi Posted October 7, 2021 Share Posted October 7, 2021 Need to add multiple machines to Citrix Catalog using Powershell , How do I do it ? I know the command but how do I run for multiple machine using loop and get content from two files I tried this way , but didn't worked - Its adding only the first one (looks like I am not doing right loop for two variables ) The command I am doing is correct but need help with PS script for adding multiple machines using loops. --------------------- $MachineName = Get-Content "c:\temp\MachineName.txt" $HostID =Get-Content "c:\temp\HostID.txt" foreach ($MachineName in $MachineName) { foreach ($HostID in $HostID) { New-BrokerMachine -MachineName $MachineName -HostedMachineId $HostID -CatalogUid 9 -HypervisorConnectionUid 2 } } Link to comment
0 James Kindon Posted October 9, 2021 Share Posted October 9, 2021 Fix your first for each loop ($Machine in $MachineName) as a starting point, then you’ll need to alter your new-brokermachine to reference the $Machine.MachineName why the two files, that’s going to need validation and lookups/matching… can’t just pull into one and reference accordingly? Link to comment
Question
Nishant Joshi
Need to add multiple machines to Citrix Catalog using Powershell , How do I do it ?
I know the command but how do I run for multiple machine using loop and get content from two files
I tried this way , but didn't worked - Its adding only the first one (looks like I am not doing right loop for two variables )
The command I am doing is correct but need help with PS script for adding multiple machines using loops.
---------------------
$MachineName = Get-Content "c:\temp\MachineName.txt"
$HostID =Get-Content "c:\temp\HostID.txt"
foreach ($MachineName in $MachineName)
{
foreach ($HostID in $HostID)
{
New-BrokerMachine -MachineName $MachineName -HostedMachineId $HostID -CatalogUid 9 -HypervisorConnectionUid 2
}
}
Link to comment
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now