Created
November 7, 2017 01:29
-
-
Save itpropro/0911d5f1b4d221805053c6353a1149a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertto-cidr | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[parameter(Mandatory=$true, ValueFromPipeline=$true)] | |
[string]$netmask | |
) | |
$cidr = '' | |
foreach ($segment in $netmask.split('.')) | |
{ | |
$cidr += [convert]::ToString($segment,2) | |
} | |
($cidr.split('1').Length) - 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment