49 lines
1.2 KiB
Text
49 lines
1.2 KiB
Text
Function Get-IPv4Scopes
|
|
<#
|
|
.SYNOPSIS
|
|
Read IPv4Scopes from an array of servers
|
|
.PARAMETER Servers
|
|
Specifies an array of servers
|
|
.EXAMPLE
|
|
Get-IPv4Scopes
|
|
|
|
Will prompt for all inputs
|
|
#>
|
|
{
|
|
[CmdletBinding()]
|
|
Param(
|
|
# 1
|
|
[parameter(
|
|
Mandatory=$true,
|
|
Position=0,
|
|
ValueFromPipelineByPropertyName=$true,
|
|
HelpMessage="Server List"
|
|
)]
|
|
[string[]]$Servers,
|
|
#2
|
|
[parameter(Mandatory=$false,ValueFromPipeline=$false)]
|
|
[bool]$Unique=$false
|
|
) #EndParam
|
|
|
|
Begin {}
|
|
|
|
Process {
|
|
$arrayJobs=@()
|
|
foreach ($server in $Servers) {
|
|
$arrayJobs+=Invoke-Command -ComputerName $server -scriptblock {Get-DhcpServerv4Scope} -AsJob
|
|
}
|
|
$complete=$false
|
|
while (-not $complete) {
|
|
$arrayJobsInProgress= $arrayJobs | Where-Object { $_.State -match 'running' }
|
|
if (-not $arrayJobsInProgress) { $complete=$true }
|
|
}
|
|
$Scopes=$arrayJobs|Receive-Job
|
|
$UniqueScopes=$Scopes|Sort-Object -Property ScopeId -Unique
|
|
}
|
|
|
|
End {
|
|
if ($Unique) { return $UniqueScopes }
|
|
else { return $Scopes }
|
|
}
|
|
|
|
} #end function
|