I am attempting to add on to an object before displaying it with an Out-GridView. I am doing the method below however get an error message. I'm not strong enough in Powershell objects to understand what I'm doing wrong here.
Any guidance is appreciated!
$scopes = Get-DhcpServerv4Scope -ComputerName $SERVERNAME
$scopeObject = @{}
foreach ($scope in $scopes) {
$stats = Get-DhcpServerv4ScopeStatistics -ComputerName 'nfiv-dhcp-02' -ScopeId $scope.ScopeId
$scopeObject.Add($scope.ScopeId,$scope.Name,$stats.Free)
}
$scopeObject | Out-GridView -Passthru -Title "DHCP Server Scopes on $SERVERNAME"
Instead of merging objects then displaying, this method grabs the number of "Free IPs" while iterating through the scopes. Not sure if this is exactly what you want, but it will give the output you specify in your
Out-Gridview
cmdlet and it should "PassThru" that same information to whatever you've left off from your snippet. Make sure you select the scopes you'd like to "PassThru."