IPTools.psm1
Function Show-IPv4Range { <# .SYNOPSIS Generate a list of IPv4 addresses between the first and the last IP address. .DESCRIPTION This function receives two IPv4 addresses and generate a list of IP addresses between the first and the last one. .EXAMPLE Show-IPv4Range -FirstIP 10.3.255.254 -LastIP 10.4.0.2 10.3.255.254 10.3.255.255 10.4.0.0 10.4.0.1 10.4.0.2 .PARAMETER FirstIP The first IPv4 address. .PARAMETER LastIP The last IPv4 address. .LINK https://github.com/brunobritorj .NOTES Author: Bruno B Silva - brunobritorj@gmail.com #> [CmdletBinding()] Param ( [Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$True)] [IPAddress]$FirstIP, [Parameter(Mandatory=$True,Position=1,ValueFromPipeline=$True)] [IPAddress]$LastIP ) Process { $FirstIP.IPAddressToString While ($FirstIP -ne $LastIP) { If ($FirstIP.GetAddressBytes()[3] -ne 255) { $FirstIP.Address += 16777216 } Elseif ($FirstIP.GetAddressBytes()[2] -ne 255) { $FirstIP.Address += -4278124544 } Elseif ($FirstIP.GetAddressBytes()[1] -ne 255) { $FirstIP.Address += -4294901504 } Elseif ($FirstIP.GetAddressBytes()[0] -ne 255) { $FirstIP.Address += -4294967039 } Else { $LastIP = $FirstIP } $FirstIP.IPAddressToString } } } Function Get-MD5Hash { <# .SYNOPSIS Get the MD5 hash from some file. .DESCRIPTION This function receives a filename and returns the MD5 hash. .EXAMPLE Get-MD5Hash -File '.\YourFile.txt' 2D1DE770FD2832F0AE3E0928E19EA60A .PARAMETER File The file path\name that will be compared. .LINK https://github.com/brunobritorj .NOTES Author: Bruno B Silva - brunobritorj@outlook.com #> Param ( [Parameter(Mandatory=$True,ValueFromPipeline=$True)] [string]$File ) Process { $MD5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider $Hash = [System.BitConverter]::ToString($MD5.ComputeHash([System.IO.File]::ReadAllBytes($File))) -replace '-' } End { Return $Hash } } |