Last active
December 19, 2016 15:45
-
-
Save biacz/58b508d76dbf7fc1cdd4f7c4949b0186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$brokers = "mapvasdfp02", "natviasdf2", "stpvasdf02" | |
$vcenters = "mapvasdfp02", "natasdf2", "stasdfp02" | |
#$creds = Get-Credential -Message "Please enter your credentials" | |
"Connecting to vCenter Servers" | |
connect-viserver $vcenters -Credential $creds | |
Set-StrictMode -Version 2.0 | |
function return-pools() | |
{ | |
param([string[]]$brokers) | |
$results = @() | |
ForEach ($broker in $brokers) { | |
$session = New-PSSession -ComputerName $broker | |
Invoke-Command -session $session -ScriptBlock { | |
Add-PSSnapin *vmware* | |
} | |
$results += Invoke-Command -session $session -ScriptBlock { | |
$result = @() | |
$object = [PSCustomObject]@{'Name' = ''; 'Template' = ''; 'Cluster' = ''; 'Datastores' = '';} | |
$pools = Get-Pool | select pool_id, poolType, templatepath, resourcepoolpath, datastorepaths | |
foreach($pool in $pools) { | |
if($pool.poolType -eq "Persistent") { | |
$objloop = $object.PSObject.Copy() | |
$objloop.Datastores = @() | |
$objloop.Name = $pool.pool_id | |
$objloop.Template = $pool.templatepath | |
$objloop.Cluster = $pool.resourcepoolpath | |
$pool.datastorepaths.split(";") | Out-Null | |
$pool.datastorepaths -replace "(.*\/)","" | out-null | |
$objloop.Datastores = $pool.datastorepaths | |
} | |
$result += $objloop | |
} | |
$result | ft | |
} | |
Remove-PSSession $session | |
} | |
$results | ft | |
} | |
return-pools($brokers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
looking for the output of $results. not getting anything.
$result inside the for loop is totally fine and being populated with the right data