Hi NG,
I got a script here from which I want to create a little table that wraps together:
- the URL from the XenServer poolmaster and
- the XenDesktop machine catalogs that are pointing to it
The result should look sort of like this:
poolmaster machine catalog
http://1234567 Catalog 1
Catalog 2
Catalog 3
http://6789832 Catalog 1
Catalog 2
My issue is that I use a hash table…well from what I understand so far but only the last foreach interation is in the hash table. The script itself is technically working as I can see on the console.
Add-PSSnapin Citrix*
Add-PSSnapin xenserver
$stradminaddress = “MYDELIVERYCONTROLLER”
$currentVDArelease = “-V1234-”
Login Data
$credentials = Get-Credential -UserName "MYDOMAIN" -Message “Enter your domain credentials here”
Get all Poolmaster IPs from XenDesktop broker
$poolmasterips = get-ChildItem xdhyp:\connections -AdminAddress $stradminaddress | select -ExpandProperty HypervisorAddress -Unique
$poolmasterips
#Connect to all poolmasters
foreach ($poolmasterip in $poolmasterips)
{
try
{
connect-xenserver -url $poolmasterip -Creds $credentials
}
catch
{
write-output "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
write-output "Could not connect to $poolmasterip"
write-output "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
}
}
Get all Poolnames
$xensession = get-xensession | select -ExpandProperty opaque_ref
$poolnames = $xensession | foreach {(get-xenpool -SessionOpaqueRef $_).name_label}
Check if newest release Machine catalog exist for Standard and Premium
Check each Poolmaster IP for existing current VDA release machine catalogs
foreach ($poolmasterip in $poolmasterips)
{
Get hypervisorconnection names from pool master IP
write-output “STEP 1:---------------------------------------------------------”
write-output “Getting host connection names for poolmaster ip $poolmasterip…”
$hypervisornames = get-childitem xdhyp:\connections -AdminAddress $stradminaddress | where {$_.HypervisorAddress -eq $poolmasterip} | select -ExpandProperty HypervisorConnectionName
$hypervisornames
write-output “Done with STEP 1!”
Write-output “----------------------------------------------------------------”
foreach ($hypervisorname in $hypervisornames)
{
# Get hosting unit Uid by host connection names
write-output "STEP 2:---------------------------------------------------------"
write-output "Getting hosting unit Uid by host connection names for $hypervisorname..."
$hostingunitids = Get-ChildItem xdhyp:\hostingunits -AdminAddress $stradminaddress | where {$_.HypervisorConnection -like "*$hypervisorname*"} | select -ExpandProperty HostingUnitUid | select -ExpandProperty GuiD
$hostingunitids
write-output "Done with STEP 2!"
Write-output "----------------------------------------------------------------------"
# Cycle through $hostingunitids and retrieve prov schemes and put them in a list
$ProvisioningSchemelist = foreach ($hostingunitid in $hostingunitids)
{
$provschemeid = Get-ProvScheme -AdminAddress $stradminaddress | where {$_.HostingUnitUid -like "*$hostingunitid*"} | select -ExpandProperty ProvisioningSchemeUid | select -ExpandProperty Guid
@($provschemeid)
}
foreach ($ProvisioningSchemeUid in $ProvisioningSchemelist)
{
# Get machine catalogs matching the Provisioning Schema ID
write-output "STEP 3:---------------------------------------------------------"
write-output "Getting machine catalogs matching the Provisioning Schema ID $ProvisioningSchemeUid..."
$brokercatalogs = get-brokercatalog -AdminAddress $stradminaddress | where {$_.PvsForVM -like "*$ProvisioningSchemeUid*"} | select -expandproperty name
$brokercatalogs
Write-Output "Done with STEP 3!"
Write-output "------------------------------------------------------------------"
$PoolmasterCataloglist = @{PoolmasterIP=$poolmasterip; BrokerCatalog=$brokercatalogs}
}
}
}
$PoolmasterCataloglist
get-xensession | Disconnect-XenServer
-------------- END -----------------
Regards
Christian