Files
Sandbox/Network-ConvertCIDRtoSubnetMask.ps1
T
Zack Meier 03dba08135 sync
2026-04-15 15:42:41 -05:00

46 lines
1.1 KiB
PowerShell

Function Convert-RvNetInt64ToIpAddress()
{
<#
.DESCRIPTION
Developer
Developer: Rudolf Vesely, http://rudolfvesely.com/
Copyright (c) Rudolf Vesely. All rights reserved
License: Free for private use only
#>
Param
(
[int64]
$Int64
)
# Return
'{0}.{1}.{2}.{3}' -f ([math]::Truncate($Int64 / 16777216)).ToString(),
([math]::Truncate(($Int64 % 16777216) / 65536)).ToString(),
([math]::Truncate(($Int64 % 65536)/256)).ToString(),
([math]::Truncate($Int64 % 256)).ToString()
}
Function Convert-RvNetSubnetMaskCidrToClasses
{
<#
.DESCRIPTION
Developer
Developer: Rudolf Vesely, http://rudolfvesely.com/
Copyright (c) Rudolf Vesely. All rights reserved
License: Free for private use only
#>
Param
(
[int]
$SubnetMaskCidr
)
# Return
Convert-RvNetInt64ToIpAddress -Int64 ([convert]::ToInt64(('1' * $SubnetMaskInt + '0' * (32 - $SubnetMaskInt)), 2))
}
$SubnetMaskInt = 28