2019-12-11 10:14:35 -05:00
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Used to convert an IPv6 address to binary.
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
ConvertTo-IcingaIPv6 returns a binary string based on the given IPv6 address.
|
|
|
|
|
|
|
|
|
|
More Information on https://github.com/Icinga/icinga-powershell-framework
|
|
|
|
|
.FUNCTIONALITY
|
|
|
|
|
This module is intended to be used to convert an IPv6 address to binary string. Its recommended to use ConvertTo-IcingaIPBinaryString as a smart function instead.
|
|
|
|
|
.PARAMETER IP
|
|
|
|
|
Used to specify an IPv6 address.
|
|
|
|
|
.INPUTS
|
|
|
|
|
System.String
|
|
|
|
|
.OUTPUTS
|
|
|
|
|
System.String
|
|
|
|
|
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/Icinga/icinga-powershell-framework
|
|
|
|
|
.NOTES
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
function ConvertTo-IcingaIPv6BinaryString()
|
|
|
|
|
{
|
|
|
|
|
param(
|
|
|
|
|
[string]$IP
|
|
|
|
|
);
|
2019-12-12 08:19:37 -05:00
|
|
|
[string]$IP = Expand-IcingaIPv6String $IP;
|
2019-12-11 10:14:35 -05:00
|
|
|
[array]$IPArr = $IP.Split(':');
|
|
|
|
|
|
|
|
|
|
$IPArr = $IPArr.ToCharArray();
|
|
|
|
|
$IP = $IPArr | ForEach-Object {
|
2020-08-04 08:48:32 -04:00
|
|
|
[System.Convert]::ToString("0x$_", 2).PadLeft(4, '0');
|
2019-12-11 10:14:35 -05:00
|
|
|
}
|
|
|
|
|
$IP = $IP -join '';
|
2020-08-04 08:48:32 -04:00
|
|
|
$IP = $IP -replace '\s', '';
|
2019-12-11 10:14:35 -05:00
|
|
|
|
2019-12-12 08:19:37 -05:00
|
|
|
return @{
|
2020-08-04 08:48:32 -04:00
|
|
|
'value' = $IP;
|
2020-08-04 09:13:04 -04:00
|
|
|
'name' = 'IPv6'
|
2020-08-04 08:48:32 -04:00
|
|
|
}
|
2019-12-12 08:19:37 -05:00
|
|
|
}
|