Skip to content
Snippets Groups Projects
Commit 45c2f2f0 authored by Aaron's avatar Aaron
Browse files

Update powershell

powershell syntax demo
parent 9b27162a
No related branches found
No related tags found
No related merge requests found
# If not running interactively, don't do anything
[[ -z "$PS1" ]] && return
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment