-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-BroadcastIp.ps1
More file actions
46 lines (42 loc) · 1.32 KB
/
Get-BroadcastIp.ps1
File metadata and controls
46 lines (42 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function Get-BroadcastIp {
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[string]$networkId
,
[Parameter(Mandatory = $false)]
[string]$ip
,
[Parameter(Mandatory = $false)]
[string]$subnet
,
[Parameter(Mandatory = $false)]
[int]$cidr
)
begin {
Write-Verbose -Message ((Get-ResStr 'STARTING_FUNCTION') -f $myInvocation.Mycommand)
New-Variable -Name 'maxHosts' -Scope 'Private' -Value ([int32]0)
New-Variable -Name 'result' -Scope 'Private' -Value ([string]'')
$initialVariables = Get-CurrentVariables -Debug:$DebugPreference
}
process {
try {
if ((! $subnet) -and (! $cidr)) {
$subnet = Get-Subnet # get it from localIp
}
if (! $networkId) {
$networkId = Get-NetworkId -ip $ip -subnet $subnet -cidr $cidr
}
$maxHosts = Get-MaxHosts -subnet $subnet -cidr $cidr
$result = Get-NextIp -ip $networkId -inc ($maxHosts + 1)
}
catch {
$result= '0.0.0.0'
}
}
end {
Get-CurrentVariables -InitialVariables $initialVariables -Debug:$DebugPreference
Return $result
}
# Test: Get-BroadcastIp -networkId 192.168.192.8 -cidr 30
}