├── Indented.Common ├── Indented.Common.Format.ps1xml ├── Indented.Common.psd1 ├── Indented.Common.psm1 └── func │ ├── Compare-Array.ps1 │ ├── ConvertFrom-XPathNode.ps1 │ ├── ConvertTo-Byte.ps1 │ ├── ConvertTo-String.ps1 │ ├── ConvertTo-TimeSpanString.ps1 │ ├── ConvertTo-Type.ps1 │ ├── ConvertTo-Xml.ps1 │ ├── Get-CommandParameters.ps1 │ ├── Get-Hash.ps1 │ ├── New-DynamicModuleBuilder.ps1 │ ├── New-DynamicParameter.ps1 │ ├── New-Enum.ps1 │ ├── New-XPathNavigator.ps1 │ ├── Set-XPathAttribute.ps1 │ └── Update-PropertyOrder.ps1 ├── Indented.DnsResolver ├── Indented.DnsResolver.Format.ps1xml ├── Indented.DnsResolver.psd1 ├── Indented.DnsResolver.psm1 ├── enum │ ├── Indented.DnsResolver.AFSDBSubType.ps1 │ ├── Indented.DnsResolver.ATMAFormat.ps1 │ ├── Indented.DnsResolver.CertificateType.ps1 │ ├── Indented.DnsResolver.DigestType.ps1 │ ├── Indented.DnsResolver.EDnsOptionCode.ps1 │ ├── Indented.DnsResolver.EDnsSECOK.ps1 │ ├── Indented.DnsResolver.EncryptionAlgorithm.ps1 │ ├── Indented.DnsResolver.Flags.ps1 │ ├── Indented.DnsResolver.IPSECAlgorithm.ps1 │ ├── Indented.DnsResolver.IPSECGatewayType.ps1 │ ├── Indented.DnsResolver.IanaAddressFamily.ps1 │ ├── Indented.DnsResolver.KEYAC.ps1 │ ├── Indented.DnsResolver.KEYNameType.ps1 │ ├── Indented.DnsResolver.KEYProtocol.ps1 │ ├── Indented.DnsResolver.LLQErrorCode.ps1 │ ├── Indented.DnsResolver.LLQOpCode.ps1 │ ├── Indented.DnsResolver.MSDNSOption.ps1 │ ├── Indented.DnsResolver.MessageCompression.ps1 │ ├── Indented.DnsResolver.NSEC3Flags.ps1 │ ├── Indented.DnsResolver.NSEC3HashAlgorithm.ps1 │ ├── Indented.DnsResolver.QR.ps1 │ ├── Indented.DnsResolver.RCode.ps1 │ ├── Indented.DnsResolver.RecordClass.ps1 │ ├── Indented.DnsResolver.RecordType.ps1 │ ├── Indented.DnsResolver.SSHAlgorithm.ps1 │ ├── Indented.DnsResolver.SSHFPType.ps1 │ ├── Indented.DnsResolver.TKEYMode.ps1 │ └── Indented.DnsResolver.WINSMappingFlag.ps1 ├── func-priv │ ├── ConvertFromDnsDomainName.ps1 │ ├── ConvertToDnsDomainName.ps1 │ ├── NewDnsMessage.ps1 │ ├── NewDnsMessageHeader.ps1 │ ├── NewDnsMessageQuestion.ps1 │ ├── NewDnsOPTRecord.ps1 │ ├── NewDnsSOARecord.ps1 │ ├── ReadDnsA6Record.ps1 │ ├── ReadDnsAAAARecord.ps1 │ ├── ReadDnsAFSDBRecord.ps1 │ ├── ReadDnsAPLRecord.ps1 │ ├── ReadDnsARecord.ps1 │ ├── ReadDnsATMARecord.ps1 │ ├── ReadDnsCERTRecord.ps1 │ ├── ReadDnsCNAMERecord.ps1 │ ├── ReadDnsCharacterString.ps1 │ ├── ReadDnsDHCIDRecord.ps1 │ ├── ReadDnsDLVRecord.ps1 │ ├── ReadDnsDNAMERecord.ps1 │ ├── ReadDnsDNSKEYRecord.ps1 │ ├── ReadDnsDSRecord.ps1 │ ├── ReadDnsEIDRecord.ps1 │ ├── ReadDnsGPOSRecord.ps1 │ ├── ReadDnsHINFORecord.ps1 │ ├── ReadDnsHIPRecord.ps1 │ ├── ReadDnsIPSECKEYRecord.ps1 │ ├── ReadDnsISDNRecord.ps1 │ ├── ReadDnsKEYRecord.ps1 │ ├── ReadDnsKXRecord.ps1 │ ├── ReadDnsLOCRecord.ps1 │ ├── ReadDnsMBRecord.ps1 │ ├── ReadDnsMDRecord.ps1 │ ├── ReadDnsMFRecord.ps1 │ ├── ReadDnsMGRecord.ps1 │ ├── ReadDnsMINFORecord.ps1 │ ├── ReadDnsMRRecord.ps1 │ ├── ReadDnsMXRecord.ps1 │ ├── ReadDnsMessage.ps1 │ ├── ReadDnsMessageHeader.ps1 │ ├── ReadDnsMessageQuestion.ps1 │ ├── ReadDnsNAPTRRecord.ps1 │ ├── ReadDnsNIMLOCRecord.ps1 │ ├── ReadDnsNINFORecord.ps1 │ ├── ReadDnsNSAPRecord.ps1 │ ├── ReadDnsNSAPTRRecord.ps1 │ ├── ReadDnsNSEC3PARAMRecord.ps1 │ ├── ReadDnsNSEC3Record.ps1 │ ├── ReadDnsNSECRecord.ps1 │ ├── ReadDnsNSRecord.ps1 │ ├── ReadDnsNULLRecord.ps1 │ ├── ReadDnsNXTRecord.ps1 │ ├── ReadDnsOPTRecord.ps1 │ ├── ReadDnsPTRRecord.ps1 │ ├── ReadDnsPXRecord.ps1 │ ├── ReadDnsRKEYRecord.ps1 │ ├── ReadDnsRPRecord.ps1 │ ├── ReadDnsRRSIGRecord.ps1 │ ├── ReadDnsRTRecord.ps1 │ ├── ReadDnsResourceRecord.ps1 │ ├── ReadDnsSIGRecord.ps1 │ ├── ReadDnsSINKRecord.ps1 │ ├── ReadDnsSOARecord.ps1 │ ├── ReadDnsSPFRecord.ps1 │ ├── ReadDnsSRVRecord.ps1 │ ├── ReadDnsSSHFPPRecord.ps1 │ ├── ReadDnsTARecord.ps1 │ ├── ReadDnsTKEYRecord.ps1 │ ├── ReadDnsTSIGRecord.ps1 │ ├── ReadDnsTXTRecord.ps1 │ ├── ReadDnsUnknownRecord.ps1 │ ├── ReadDnsWINSRRecord.ps1 │ ├── ReadDnsWINSRecord.ps1 │ ├── ReadDnsWKSRecord.ps1 │ └── ReadDnsX25Record.ps1 ├── func │ ├── Add-InternalDnsCacheRecord.ps1 │ ├── Get-Dns.ps1 │ ├── Get-DnsServerList.ps1 │ ├── Get-InternalDnsCacheRecord.ps1 │ ├── Initialize-InternalDnsCache.ps1 │ ├── Remove-InternalDnsCacheRecord.ps1 │ └── Update-InternalRootHints.ps1 └── var │ └── named.root ├── Indented.NetworkTools ├── Indented.NetworkTools.Format.ps1xml ├── Indented.NetworkTools.psd1 ├── Indented.NetworkTools.psm1 ├── func-priv │ └── ConvertToNetworkObject.ps1 └── func │ ├── Connect-Socket.ps1 │ ├── ConvertFrom-HexIP.ps1 │ ├── ConvertTo-BinaryIP.ps1 │ ├── ConvertTo-DecimalIP.ps1 │ ├── ConvertTo-DottedDecimalIP.ps1 │ ├── ConvertTo-HexIP.ps1 │ ├── ConvertTo-Mask.ps1 │ ├── ConvertTo-MaskLength.ps1 │ ├── ConvertTo-Subnet.ps1 │ ├── Disconnect-Socket.ps1 │ ├── Get-BroadcastAddress.ps1 │ ├── Get-NetworkAddress.ps1 │ ├── Get-NetworkRange.ps1 │ ├── Get-NetworkSummary.ps1 │ ├── Get-Subnets.ps1 │ ├── Get-WebContent.ps1 │ ├── Get-WhoIs.ps1 │ ├── New-BinaryReader.ps1 │ ├── New-Socket.ps1 │ ├── Receive-Bytes.ps1 │ ├── Remove-Socket.ps1 │ ├── Send-Bytes.ps1 │ ├── Test-SmtpServer.ps1 │ ├── Test-SubnetMember.ps1 │ ├── Test-TcpPort.ps1 │ └── Test-UdpPort.ps1 ├── Indented.Utility ├── Indented.Utility.psd1 ├── Indented.Utility.psm1 └── func │ ├── Get-Manufacturer.ps1 │ ├── Select-HIString.ps1 │ └── Update-ManufacturerList.ps1 ├── LICENSE └── README.md /Indented.Common/Indented.Common.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.Common/Indented.Common.psd1 -------------------------------------------------------------------------------- /Indented.Common/Indented.Common.psm1: -------------------------------------------------------------------------------- 1 | # 2 | # Module loader for Indented.Common 3 | # 4 | # Author: Chris Dent 5 | # 6 | 7 | # Public functions 8 | $Public = 'Compare-Array', 9 | 'ConvertFrom-XPathNode', 10 | 'ConvertTo-Byte', 11 | 'ConvertTo-String', 12 | 'ConvertTo-TimeSpanString', 13 | 'ConvertTo-Type', 14 | 'ConvertTo-Xml', 15 | 'Get-CommandParameters', 16 | 'Get-Hash', 17 | 'New-DynamicModuleBuilder', 18 | 'New-DynamicParameter', 19 | 'New-Enum', 20 | 'New-XPathNavigator', 21 | 'Set-XPathAttribute', 22 | 'Update-PropertyOrder' 23 | 24 | $Public | ForEach-Object { 25 | Import-Module "$psscriptroot\func\$_.ps1" 26 | } -------------------------------------------------------------------------------- /Indented.Common/func/Compare-Array.ps1: -------------------------------------------------------------------------------- 1 | function Compare-Array { 2 | # .SYNOPSIS 3 | # Compares two arrays to determine equality. 4 | # .DESCRIPTION 5 | # This function presents two methods of comparing arrays. 6 | # 7 | # 1. A manual loop comparison method, exiting at the first opportunity. 8 | # 2. A wrapper around the .NET 4 IStructuralEquatable interface. 9 | # 10 | # Arrays must be exactly equal for the function to return true. That is, arrays must meet the following criteria: 11 | # 12 | # * Must use simple values (primitive types). 13 | # * Must be of equal length. 14 | # * Must be ordered in the same way unless using the Sort parameter. 15 | # * When comparing strings, case is important. 16 | # * .NET Type must be equal (UInt32 is not the same as Int32). 17 | # 18 | # .PARAMETER Object 19 | # The object array to test against. 20 | # .PARAMETER Sort 21 | # For an array to be considered equal it must also be ordered in the same way. Comparison of unordered arrays can be forced by setting this parameter. 22 | # .PARAMETER Subject 23 | # The object array to test. 24 | # .INPUTS 25 | # System.Array 26 | # System.Object[] 27 | # .OUTPUTS 28 | # System.Boolean 29 | # .EXAMPLE 30 | # C:\PS>Compare-Array -Subject 1, 2, 3 -Object 1, 2, 3 31 | # 32 | # Returns true. 33 | # .EXAMPLE 34 | # C:\PS>$a = [Byte[]](1, 2, 3) 35 | # C:\PS>$b = [Byte[]](3, 2, 1) 36 | # C:\PS>Compare-Array -Subject $a -Object $b 37 | # 38 | # Returns false, elements are not ordered in the same way and types are equal. 39 | # .EXAMPLE 40 | # C:\PS>$a = [Byte[]](1, 2, 3) 41 | # C:\PS>$a = [UInt32[]](1, 2, 3) 42 | # C:\PS>Compare-Array $a $b 43 | # 44 | # Returns false, element Types are not equal. 45 | # .EXAMPLE 46 | # C:\PS>$a = "one", "two" 47 | # C:\PS>$b = "one", "two" 48 | # C:\PS>Compare-Array $a $b 49 | # 50 | # Returns true. 51 | # .EXAMPLE 52 | # C:\PS>$a = "ONE", "TWO" 53 | # C:\PS>$b = "one", "two" 54 | # C:\PS>Compare-Array $a $b 55 | # 56 | # Returns false. 57 | # .EXAMPLE 58 | # C:\PS>$a = 1..10000 59 | # C:\PS>$b = 1..10000 60 | # C:\PS>Compare-Array $a $b -ManualLoop 61 | # 62 | # Returns true. 63 | # .EXAMPLE 64 | # C:\PS> Compare-Array @("1.2.3.4", "2.3.4.5") @("2.3.4.5", "1.2.3.4") -Sort 65 | # 66 | # Returns true. 67 | # .NOTES 68 | # Author: Chris Dent 69 | # 70 | # Change log: 71 | # 02/04/2014 - Chris Dent - Created. 72 | 73 | param( 74 | [Parameter(Mandatory = $true)] 75 | [Object[]]$Subject, 76 | 77 | [Parameter(Mandatory = $true)] 78 | [Object[]]$Object, 79 | 80 | [Switch]$ManualLoop, 81 | 82 | [Switch]$Sort 83 | ) 84 | 85 | if ($ManualLoop) { 86 | # If the arrays are not the same length they cannot be equal. 87 | if ($Subject.Length -ne $Object.Length) { 88 | return $false 89 | } 90 | 91 | # If Sort is set and the arrays are of equal length ensure both arrays are similarly ordered. 92 | if ($Sort) { 93 | $Subject = $Subject | Sort-Object 94 | $Object = $Object | Sort-Object 95 | } 96 | 97 | $Length = $Subject.Length 98 | $Equal = $true 99 | for ($i = 0; $i -lt $Length; $i++) { 100 | # Exit when the first match fails. 101 | if ($Subject[$i] -ne $Object[$i]) { 102 | return $false 103 | } 104 | } 105 | return $true 106 | } else { 107 | # If Sort is set and the arrays are of equal length ensure both arrays are similarly ordered. 108 | if ($Sort) { 109 | $Subject = $Subject | Sort-Object 110 | $Object = $Object | Sort-Object 111 | } 112 | 113 | ([Collections.IStructuralEquatable]$Subject).Equals( 114 | $Object, 115 | [Collections.StructuralComparisons]::StructuralEqualityComparer 116 | ) 117 | } 118 | } -------------------------------------------------------------------------------- /Indented.Common/func/ConvertFrom-XPathNode.ps1: -------------------------------------------------------------------------------- 1 | function ConvertFrom-XPathNode { 2 | # .SYNOPSIS 3 | # Convert from an XPathDocumentNavigator node-set to the specified type. 4 | # .DESCRIPTION 5 | # ConvertFrom-XPathNode simplifies reading XML documents using the XPathNavigator. The node-set in the input pipeline is converted to the requested type. 6 | # .PARAMETER MergeHashtable 7 | # An existing Hashtable may be appended to the beginning of the new hashtable. 8 | # .PARAMETER ToArray 9 | # Convert a list of values to an array. 10 | # .PARAMETER ToHashtable 11 | # Convert a set of values to a Hashtable. The first element in the input pipeline is treated as the key. 12 | # .PARAMETER ToObject 13 | # Attempt to convert the XML node to an PSObject. 14 | # .PARAMETER ToString 15 | # A single node is expected, the value is returned as a string. If the value is true or false the respective boolean value is returned instead. 16 | # .PARAMETER UseAttribute 17 | # Use the named attribute as the key for a hashtable. 18 | # .PARAMETER UseTypeAttribute 19 | # Look for a Type attribute on the XML node and attempt to convert the value to the specified type. 20 | # .PARAMETER XmlNode 21 | # A XPathNodeIterator node-set selected from an XPathNavigator object. 22 | # .INPUTS 23 | # System.Hashtable 24 | # System.Xml.XPath.XPathNodeIterator 25 | # .OUTPUTS 26 | # System.Array 27 | # System.Boolean 28 | # System.Collections.Specialized.OrderedDictionary 29 | # System.String 30 | # .EXAMPLE 31 | # $XPathNavigator.Select("/Node") | ConvertFrom-XPathNode -ToString 32 | # .NOTES 33 | # Author: Chris Dent 34 | # 35 | # Change log: 36 | # 24/10/2014 - Chris Dent - Added support for arrays (as nested ArrayItem). 37 | # 22/10/2014 - Chris Dent - Added type converter. 38 | # 04/07/2014 - Chris Dent - Added ToObject. 39 | # 02/07/2014 - Chris Dent - Added boolean type conversion to the Hashtable reader. 40 | # 01/07/2014 - Chris Dent - Created. 41 | 42 | [CmdLetBinding(DefaultParameterSetName = 'ToString')] 43 | param( 44 | [Parameter(ValueFromPipeline = $true)] 45 | [ValidateScript( { $_.PSObject.TypeNames -contains 'MS.Internal.Xml.Cache.XPathDocumentNavigator' -or $_.PSObject.TypeNames -contains 'System.Xml.DocumentXPathNavigator' } )] 46 | $XmlNode, 47 | 48 | [Parameter(ParameterSetName = 'ToArray')] 49 | [Switch]$ToArray, 50 | 51 | [Parameter(ParameterSetName = 'ToHashtable')] 52 | [Switch]$ToHashtable, 53 | 54 | [Parameter(ParameterSetName = 'ToHashtable')] 55 | [Collections.Specialized.OrderedDictionary]$MergeHashtable, 56 | 57 | [Parameter(ParameterSetName = 'ToHashtable')] 58 | [String]$UseAttribute, 59 | 60 | [Parameter(ParameterSetName = 'ToObject')] 61 | [Switch]$ToObject, 62 | 63 | [Parameter(ParameterSetName = 'ToString')] 64 | [Switch]$ToString, 65 | 66 | [Switch]$UseTypeAttribute 67 | ) 68 | 69 | begin { 70 | switch ($pscmdlet.ParameterSetName) { 71 | 'ToArray' { $Array = @() } 72 | 'ToHashtable' { 73 | $Hashtable = [Ordered]@{} 74 | if ($MergeHashtable) { 75 | $MergeHashtable.Keys | ForEach-Object { 76 | $Hashtable.Add($_, $MergeHashtable[$_]) 77 | } 78 | } 79 | } 80 | } 81 | } 82 | 83 | process { 84 | switch ($pscmdlet.ParameterSetName) { 85 | 'ToArray' { 86 | $Array += $XmlNode.Select('./*') | ForEach-Object { 87 | if ($UseTypeAttribute) { 88 | $Type = $_.GetAttribute("Type", "") 89 | ConvertTo-Type $_.Value $Type 90 | } else { 91 | ConvertTo-Type $_.Value $Type 92 | } 93 | } 94 | } 95 | 'ToHashtable' { 96 | $Key = $null; $Values = @() 97 | $XmlNode.Select('./*') | ForEach-Object { 98 | if ($psboundparameters.ContainsKey("UseAttribute")) { 99 | $Key = $_.GetAttribute($UseAttribute, $null) 100 | } 101 | if (-not $Key) { 102 | $Key = $_.Value 103 | } else { 104 | $Values += $_ 105 | } 106 | } 107 | if ($Values.Count -eq 1) { 108 | if ($UseTypeAttribute) { 109 | $Type = $Values.GetAttribute("Type", "") 110 | $Value = ConvertTo-Type $Values.Value $Type 111 | } else { 112 | $Value = ConvertTo-Type $Values.Value 113 | } 114 | $Hashtable.Add($Key, $Value) 115 | } else { 116 | if ($UseTypeAttribute) { 117 | $Value = $XmlNode | ConvertFrom-XPathNode -ToObject -UseTypeAttribute 118 | } else { 119 | $Value = $XmlNode | ConvertFrom-XPathNode -ToObject 120 | } 121 | $Hashtable.Add($Key, $Value) 122 | } 123 | } 124 | 'ToObject' { 125 | $Object = New-Object PSObject 126 | $XmlNode.Select("./*") | ForEach-Object { 127 | $Value = $_.Value.Trim() 128 | if ($UseTypeAttribute) { 129 | $Type = $_.GetAttribute("Type", "") 130 | if ($Type -match '\[\]$') { 131 | $Value = $_.Select("./*") | ForEach-Object { 132 | ConvertTo-Type $_.Value ($Type -replace '\[\]$') 133 | } 134 | } else { 135 | $Value = ConvertTo-Type $Value $Type 136 | } 137 | } else { 138 | $Value = ConvertTo-Type $Value 139 | } 140 | Add-Member $_.Name -MemberType NoteProperty -Value $Value -InputObject $Object 141 | } 142 | return $Object 143 | } 144 | 'ToString' { 145 | return (ConvertTo-Type $XmlNode.Value.Trim()) 146 | } 147 | } 148 | } 149 | 150 | end { 151 | switch ($pscmdlet.ParameterSetName) { 152 | 'ToArray' { return $Array } 153 | 'ToHashtable' { return $Hashtable } 154 | } 155 | } 156 | } -------------------------------------------------------------------------------- /Indented.Common/func/ConvertTo-Byte.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-Byte { 2 | # .SYNOPSIS 3 | # Converts a value to a byte array. 4 | # .DESCRIPTION 5 | # ConvertTo-Byte acts as a wrapper for a number of .NET methods which return byte arrays. 6 | # .PARAMETER BigEndian 7 | # If a multi-byte value is being returned this parameter can be used to reverse the byte order. By default, the least significant byte is returned first. 8 | # 9 | # The BigEndian parameter is only effective when a numeric value is passed as the Value. 10 | # .PARAMETER Unicode 11 | # Treat text strings as Unicode instead of ASCII. 12 | # .PARAMETER Value 13 | # The value to convert. If a string value is passed it is treated as ASCII text and converted. If a numeric value is entered the type is tested an BitConverter.GetBytes is used. 14 | # .INPUTS 15 | # System.Object 16 | # .OUTPUTS 17 | # System.Byte[] 18 | # .EXAMPLE 19 | # "The cow jumped over the moon" | ConvertTo-Byte 20 | # .EXAMPLE 21 | # 123456 | ConvertTo-Byte 22 | # .EXAMPLE 23 | # [UInt16]60000 | ConvertTo-Byte -BigEndian 24 | # .NOTES 25 | # Author: Chris Dent 26 | # 27 | # Change log: 28 | # 13/01/2015 - Chris Dent - Added Unicode option. 29 | # 25/11/2010 - Chris Dent - Created. 30 | 31 | [CmdLetBinding()] 32 | param( 33 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 34 | $Value, 35 | 36 | [Switch]$BigEndian, 37 | 38 | [Switch]$Unicode 39 | ) 40 | 41 | process { 42 | switch -Regex ($Value.GetType().Name) { 43 | 'Byte|U?Int(16|32|64)' { 44 | $Bytes = [BitConverter]::GetBytes($Value) 45 | if ($BigEndian) { 46 | [Array]::Reverse($Bytes) 47 | } 48 | return $Bytes 49 | } 50 | default { 51 | if ($Unicode) { 52 | return [Text.Encoding]::Unicode.GetBytes([String]$Value) 53 | } else { 54 | return [Text.Encoding]::ASCII.GetBytes([String]$Value) 55 | } 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Indented.Common/func/ConvertTo-String.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-String { 2 | # .SYNOPSIS 3 | # Converts a byte array to a string value. 4 | # .DESCRIPTION 5 | # ConvertTo-String supports a number of different binary encodings including ASCII, Base16 (Hexadecimal), Base64, Binary and Unicode. 6 | # .PARAMETER ASCII 7 | # The byte array is an ASCII string. 8 | # .PARAMETER Base64 9 | # The byte array is Base64 encoded string. 10 | # .PARAMETER Binary 11 | # The byte array is a binary string. 12 | # .PARAMETER Hexadecimal 13 | # The byte array is a hexadecimal string. 14 | # .PARAMETER Unicode 15 | # The byte array is a Unicode string. 16 | # .INPUTS 17 | # System.Byte[] 18 | # .OUTPUTS 19 | # System.String 20 | # .EXAMPLE 21 | # ConvertTo-String (72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100) 22 | # 23 | # Converts the byte array to an ASCII string. 24 | # .EXAMPLE 25 | # ConvertTo-String (1, 2, 3, 4) -Base64 26 | # 27 | # Converts the byte array to a Base64 string. 28 | # .EXAMPLE 29 | # ConvertTo-String (1, 2, 3, 4) -Binary 30 | # 31 | # Converts the byte array to a binary string. 32 | # .EXAMPLE 33 | # ConvertTo-String (1, 2, 3, 4) -Hexadecimal 34 | # 35 | # Converts the byte array to a hexadecimal string. 36 | # .EXAMPLE 37 | # ConvertTo-String (72, 0, 101, 0, 108, 0, 108, 0, 111, 0, 32, 0, 119, 0, 111, 0, 114, 0, 108, 0, 100, 0) -Unicode 38 | # 39 | # Converts the byte array to a unicode string. 40 | # .NOTES 41 | # Author: Chris Dent 42 | # 43 | # Change log: 44 | # 25/11/2010 - Chris Dent - Created. 45 | 46 | [CmdLetBinding(DefaultParameterSetName = 'ToASCII')] 47 | param( 48 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 49 | [Byte[]]$Data, 50 | 51 | [Parameter(Mandatory = $true, ParameterSetName = 'ToBase64')] 52 | [Alias('ToBase64')] 53 | [Switch]$Base64, 54 | 55 | [Parameter(Mandatory = $true, ParameterSetName = 'ToBinary')] 56 | [Alias('ToBinary')] 57 | [Switch]$Binary, 58 | 59 | [Parameter(Mandatory = $true, ParameterSetName = 'ToHex')] 60 | [Alias('Hex', 'ToHex', 'Base16', 'ToBase16')] 61 | [Switch]$Hexadecimal, 62 | 63 | [Parameter(Mandatory = $true, ParameterSetName = 'ToUnicode')] 64 | [Alias('ToUnicode')] 65 | [Switch]$Unicode 66 | ) 67 | 68 | process { 69 | switch ($pscmdlet.ParameterSetName) { 70 | 'ToASCII' { 71 | return [Text.Encoding]::ASCII.GetString($Data) 72 | } 73 | 'ToBase64' { 74 | return [Convert]::ToBase64String($Data) 75 | } 76 | 'ToBinary' { 77 | return (($Data | ForEach-Object { [Convert]::ToString($_, 2).PadLeft(8, '0') }) -join '') 78 | } 79 | 'ToHex' { 80 | $HexAlphabet = [Char[]]('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f') 81 | 82 | $Length = $Data.Length 83 | $ResultCharacters = New-Object Char[] ($Length * 2) 84 | for ($i = 0; $i -lt $Length; $i++) { 85 | [Byte]$Byte = $Data[$i] 86 | $j = $i * 2 87 | # Shift right to drop the last 4 bits. Allows conversion of the first of two characters. 88 | $ResultCharacters[$j] = $HexAlphabet[$Byte -shr 4] 89 | # Mask the last last 4 bits with 00001111 (15 / 0x0F). Allows conversion of the second of two characters. 90 | $ResultCharacters[$j + 1] = $HexAlphabet[$Byte -band [Byte]0xF] 91 | } 92 | 93 | return New-Object String(,$ResultCharacters) 94 | } 95 | 'ToUnicode' { 96 | return [Text.Encoding]::Unicode.GetString($Data) 97 | } 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Indented.Common/func/ConvertTo-TimeSpanString.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-TimeSpanString { 2 | # .SYNOPSIS 3 | # Converts a number of seconds to a string. 4 | # .DESCRIPTION 5 | # ConvertTo-TimeSpanString accepts values in seconds then uses integer division to represent that time as a string. 6 | # 7 | # ConvertTo-TimeSpanString accepts UInt32 values, overcoming the Int32 type limitation built into New-TimeSpan. 8 | # 9 | # The format below is used, omitting any values of 0: 10 | # 11 | # # weeks # days # hours # minutes # seconds 12 | # 13 | # .PARAMETER Seconds 14 | # A number of seconds as an unsigned 32-bit integer. The maximum value is 4294967295 ([UInt32]::MaxValue). 15 | # .INPUTS 16 | # System.UInt32 17 | # .OUTPUTS 18 | # System.String 19 | # .EXAMPLE 20 | # ConvertTo-TimeSpanString 28800 21 | # .EXAMPLE 22 | # [UInt32]::MaxValue | ConvertTo-TimeSpanString 23 | # .EXAMPLE 24 | # 86400, 700210 | ConvertTo-TimeSpanString 25 | # .NOTES 26 | # Author: Chris Dent 27 | # 28 | # Change log: 29 | # 15/10/2013 - Chris Dent - Forked from source module. 30 | 31 | [CmdLetBinding()] 32 | param( 33 | [Parameter(Mandatory = $true, ValueFromPipeLine = $true)] 34 | [UInt32]$Seconds 35 | ) 36 | 37 | begin { 38 | # Time periods described in seconds 39 | $Formats = [Ordered]@{ 40 | week = 604800; 41 | day = 86400; 42 | hour = 3600; 43 | minute = 60; 44 | second = 1; 45 | } 46 | } 47 | 48 | process { 49 | $Values = $Formats.Keys | ForEach-Object { 50 | $Key = $_ 51 | 52 | # Calculate the remainder prior to integer division 53 | $Remainder = $Seconds % $Formats[$Key] 54 | $Value = ($Seconds - $Remainder) / $Formats[$Key] 55 | # Decrement the original value 56 | $Seconds = $Remainder 57 | 58 | if ($Value) { 59 | # if the value is greater than 1, make the key name plural 60 | if ($Value -gt 1) { $Key = "$($Key)s" } 61 | 62 | "$Value $Key" 63 | } 64 | } 65 | return "$Values" 66 | } 67 | } -------------------------------------------------------------------------------- /Indented.Common/func/ConvertTo-Type.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-Type { 2 | # .SYNOPSIS 3 | # Convert a value to a named type. 4 | # .DESCRIPTION 5 | # Attempt to convert a value to a named type. If the type name cannot be resolved to a type the original value is returned unmodified. 6 | # .PARAMETER Value 7 | # The value to convert. 8 | # .PARAMETER 9 | # The type to convert to. 10 | # .INPUTS 11 | # System.Object 12 | # System.String 13 | # .OUTPUTS 14 | # System.Object 15 | # .EXAMPLE 16 | # ConvertTo-Type "01/01/2014" -Type DateTime 17 | # 18 | # Explicit conversion of a datetime string to a DateTime type. 19 | # .EXAMPLE 20 | # ConvertTo-Type "1" -Type UInt32 21 | # 22 | # Explicit conversion of a string to an unsigned 32-bit integer. 23 | # .EXAMPLE 24 | # ConvertTo-Type true 25 | # 26 | # Implicit conversion of the string true to a Boolean. 27 | # .NOTES 28 | # Author: Chris Dent 29 | # 30 | # Change log: 31 | # 19/11/2014 - Chris Dent - BugFix: ErrorAction SilentlyContinue does not work for Invoke-Expression. 32 | # 10/11/2014 - Chris Dent - Added type casting. 33 | # 22/10/2014 - Chris Dent - Created. 34 | 35 | [CmdLetBinding()] 36 | param( 37 | [Object]$Value, 38 | 39 | [String]$Type 40 | ) 41 | 42 | if ($Type -as [Type] -eq [DateTime]) { 43 | try { return (Get-Date $Value) } catch { } 44 | if (-not $?) { 45 | try { return [Convert]::ChangeType($Value, [DateTime]) } catch { } 46 | } 47 | } elseif ($Type -as [Type] -eq [Net.IPEndPoint]) { 48 | try { return (New-Object Net.IPEndPoint([IPAddress]($Value -replace ':.+$'), ($Value -replace '^.+:'))) } catch { } 49 | } elseif ($Type -as [Type]) { 50 | try { return [Convert]::ChangeType($Value, ($Type -as [Type])) } catch { } 51 | if (-not $?) { 52 | try { return (Invoke-Expression "[$(($Type -as [Type]).FullName)]'$Value'") } catch { } 53 | } 54 | } elseif ($Value -match '^(true|false)$') { 55 | return [Convert]::ToBoolean($Value) 56 | } 57 | return $Value 58 | } -------------------------------------------------------------------------------- /Indented.Common/func/ConvertTo-Xml.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-Xml { 2 | # .SYNOPSIS 3 | # Convert an object to a simple XML structure. 4 | # .DESCRIPTION 5 | # Convert an existing object to a simple XML format. 6 | # 7 | # The input object is treated as being flat. All properties are treated as strings. 8 | # .PARAMETER ChildNodeName 9 | # The name given to the wrapper for each child node. The child node will contain each property from the object. 10 | # .PARAMETER IncludeTypeNames 11 | # By default ConvertTo-XML creates an attribute on each property element containing the .NET type. This behaviour may be suppressed by setting IncludeTypeNames to false. 12 | # .PARAMETER Object 13 | # The object to convert. 14 | # .PARAMETER RootNodeName 15 | # The name of the root node (which contains all other nodes). 16 | # .INPUTS 17 | # System.Object[] 18 | # .OUTPUTS 19 | # System.String 20 | # .EXAMPLE 21 | # Get-Process | Select-Object ProcessName, StartTime, ID | ConvertTo-Xml | Out-File processes.xml 22 | # .NOTES 23 | # Author: Chris Dent 24 | # 25 | # Change log: 26 | # 27/10/2014 - Chris Dent - Suppressed ASCII characters 0x00 to 0x1F in XML strings. 27 | # 24/10/2014 - Chris Dent - Modified DateTime to always write as a string. 28 | # 21/10/2014 - Chris Dent - Added Array support. 29 | # 04/08/2014 - Chris Dent - Created. 30 | 31 | [CmdLetBinding()] 32 | param( 33 | [Parameter(ValueFromPipeline = $true)] 34 | [Object]$Object, 35 | 36 | [String]$RootNodeName = "Objects", 37 | 38 | [String]$ChildNodeName = "Object", 39 | 40 | [Boolean]$IncludeTypeNames = $true 41 | ) 42 | 43 | begin { 44 | $StringBuilder = New-Object Text.StringBuilder 45 | 46 | $XmlWriterSettings = New-Object Xml.XmlWriterSettings 47 | $XmlWriterSettings.Indent = $true 48 | 49 | $XmlWriter = [Xml.XmlWriter]::Create($StringBuilder, $XmlWriterSettings) 50 | $XmlWriter.WriteStartElement($RootNodeName) 51 | } 52 | 53 | process { 54 | $XmlWriter.WriteStartElement($ChildNodeName) 55 | 56 | $Object.PSObject.Properties | Where-Object { $_.MemberType -like '*Property' } | ForEach-Object { 57 | $XmlWriter.WriteStartElement($_.Name) 58 | if ($IncludeTypeNames) { 59 | if ($_.Value) { 60 | $Type = $_.Value.GetType().FullName 61 | } else { 62 | $Type = "System.Object" 63 | } 64 | $XmlWriter.WriteAttributeString("Type", $Type) 65 | } 66 | if ($_.Value -is [Array]) { 67 | $_.Value | ForEach-Object { 68 | $XmlWriter.WriteStartElement("ArrayItem") 69 | if ($_ -is [DateTime]) { 70 | $XmlWriter.WriteString($_.ToString("u")) 71 | } else { 72 | $XmlWriter.WriteString(($_ -replace '[\x00-\x1F]', ' ')) 73 | } 74 | $XmlWriter.WriteEndElement() 75 | } 76 | } else { 77 | if ($_.Value -is [DateTime]) { 78 | $XmlWriter.WriteString($_.Value.ToString("u")) 79 | } else { 80 | $XmlWriter.WriteString(($_.Value -replace '[\x00-\x1F]', ' ')) 81 | } 82 | } 83 | $XmlWriter.WriteEndElement() 84 | } 85 | 86 | $XmlWriter.WriteEndElement() 87 | } 88 | 89 | end { 90 | $XmlWriter.WriteEndElement() 91 | $XmlWriter.Flush() 92 | 93 | $StringBuilder.ToString() 94 | } 95 | } -------------------------------------------------------------------------------- /Indented.Common/func/Get-CommandParameters.ps1: -------------------------------------------------------------------------------- 1 | function Get-CommandParameters { 2 | # .SYNOPSIS 3 | # Get the parameters used by a command, excluding common parameters. 4 | # .DESCRIPTION 5 | # Get-CommandParameters is used to retrieve the list of CmdLet-specific parameters to simplify parameter passing operations. 6 | # .PARAMETER Name 7 | # The name of the CmdLet or Function. 8 | # .PARAMETER ParameterNamesOnly 9 | # Return parameter names as an array of strings instead of parameter metadata. 10 | # .INPUTS 11 | # System.String 12 | # .OUTPUTS 13 | # System.Management.Automation.ParameterMetadata[] 14 | # .EXAMPLE 15 | # Get-CommandParameters Get-DSObject 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 23/07/2014 - Chris Dent - Added ShouldProcess parameters. 21 | # 24/06/2014 - Chris Dent - Created. 22 | 23 | [CmdLetBinding()] 24 | param( 25 | [Parameter(Mandatory = $true)] 26 | [ValidateNotNullOrEmpty()] 27 | [ValidateScript( { Get-Command $_ } )] 28 | [String]$Name, 29 | 30 | [Switch]$ParameterNamesOnly 31 | ) 32 | 33 | $CommonParameters = ([Management.Automation.Internal.CommonParameters]).GetProperties() | Select-Object -ExpandProperty Name 34 | $ShouldProcessParameters = ([Management.Automation.Internal.ShouldProcessParameters]).GetProperties() | Select-Object -ExpandProperty Name 35 | 36 | $ParameterHashtable = (Get-Command $Name).Parameters 37 | $Parameters = $ParameterHashtable.Keys | 38 | Where-Object { $_ -notin $CommonParameters -and $_ -notin $ShouldProcessParameters } | 39 | ForEach-Object { 40 | $ParameterHashtable[$_] 41 | } 42 | 43 | if ($ParameterNamesOnly) { 44 | return $Parameters | Select-Object -ExpandProperty Name 45 | } else { 46 | return $Parameters 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Indented.Common/func/Get-Hash.ps1: -------------------------------------------------------------------------------- 1 | function Get-Hash { 2 | # .SYNOPSIS 3 | # Get a hash for the requested object. 4 | # .DESCRIPTION 5 | # Generate a hash using .NET cryptographic service providers from the passed string, file or byte array. 6 | # .PARAMETER Algorithm 7 | # The hashing algorithm to be used. By default, Get-Hash generates an MD5 hash. 8 | # 9 | # Available algorithms are MD5, SHA1, SHA256, SHA384 and SHA512. 10 | # .PARAMETER ByteArray 11 | # Generate a hash from the byte array. 12 | # .PARAMETER FileName 13 | # Generate a hash of the file. 14 | # .PARAMETER String 15 | # Generate a hash from the specified string. 16 | # .INPUTS 17 | # System.Byte[] 18 | # System.String 19 | # .OUTPUTS 20 | # System.Byte[] 21 | # System.String 22 | # .EXAMPLE 23 | # Get-ChildItem C:\Windows | Get-Hash 24 | # .NOTES 25 | # Author: Chris Dent 26 | # 27 | # Change log: 28 | # 01/05/2015 - Chris Dent - BugFix: Open file stream. 29 | # 22/04/2014 - Chris Dent - Created. 30 | 31 | [CmdLetBinding(DefaultParameterSetName = 'String')] 32 | param( 33 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = 'String')] 34 | [String]$String, 35 | 36 | [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'FileName')] 37 | [ValidateScript( { Test-Path $_ -PathType Leaf } )] 38 | [Alias('FullName')] 39 | [String]$FileName, 40 | 41 | [Parameter(Mandatory = $true, ParameterSetName = 'ByteArray')] 42 | [Byte[]]$ByteArray, 43 | 44 | [ValidateSet('MD5', 'SHA1', 'SHA256', 'SHA384', 'SHA512')] 45 | [String]$Algorithm = "MD5", 46 | 47 | [Switch]$AsString 48 | ) 49 | 50 | begin { 51 | $CryptoServiceProvider = switch ($Algorithm) { 52 | "MD5" { New-Object Security.Cryptography.MD5CryptoServiceProvider; break } 53 | "SHA1" { New-Object Security.Cryptography.SHA1CryptoServiceProvider; break } 54 | "SHA256" { New-Object Security.Cryptography.SHA256CryptoServiceProvider; break } 55 | "SHA384" { New-Object Security.Cryptography.SHA384CryptoServiceProvider; break } 56 | "SHA512" { New-Object Security.Cryptography.SHA512CryptoServiceProvider; break } 57 | } 58 | } 59 | 60 | process { 61 | if ($pscmdlet.ParameterSetName -eq 'String') { 62 | $ByteArray = ConvertTo-Byte $String 63 | } elseif ($pscmdlet.ParameterSetName -eq 'FileName') { 64 | # Ensure the full path to the file is available 65 | $FullName = Get-Item $FileName | Select-Object -ExpandProperty FullName 66 | 67 | $FileStream = New-Object IO.FileStream($FullName, "Open", "Read", "Read") 68 | $ByteArray = New-Object Byte[] $FileStream.Length 69 | $null = $FileStream.Read($ByteArray, 0, $FileStream.Length) 70 | $FileStream.Close() 71 | } 72 | 73 | $HashValue = $CryptoServiceProvider.ComputeHash($ByteArray) 74 | 75 | if ($AsString) { 76 | ConvertTo-String $HashValue -Hexadecimal 77 | } else { 78 | $HashValue 79 | } 80 | } 81 | 82 | end { 83 | $CryptoServiceProvider.Dispose() 84 | } 85 | } -------------------------------------------------------------------------------- /Indented.Common/func/New-DynamicModuleBuilder.ps1: -------------------------------------------------------------------------------- 1 | function New-DynamicModuleBuilder { 2 | # .SYNOPSIS 3 | # Creates a new assembly and a dynamic module within the current AppDomain. 4 | # .DESCRIPTION 5 | # Prepares a System.Reflection.Emit.ModuleBuilder class to allow construction of dynamic types. The ModuleBuilder is created to allow the creation of multiple types under a single assembly. 6 | # .PARAMETER AssemblyName 7 | # A name for the in-memory assembly. 8 | # .PARAMETER UseGlobalVariable 9 | # By default, this function stores the requested ModuleBuilder in a global variable called Indented_ModuleBuilder. This leaves the ModuleBuilder object accessible to New-Enum without needing an explicit assignment operation. 10 | # .INPUTS 11 | # System.Reflection.AssemblyName 12 | # .OUTPUTS 13 | # System.Reflection.Emit.ModuleBuilder 14 | # .EXAMPLE 15 | # New-DynamicModuleBuilder "Example.Assembly" 16 | # .LINK 17 | # http://www.indented.co.uk/indented-common/ 18 | # .NOTES 19 | # Author: Chris Dent 20 | # 21 | # Change log: 22 | # 17/08/2013 - Chris Dent - Created. 23 | 24 | [CmdLetBinding()] 25 | param( 26 | [Parameter(Mandatory = $true)] 27 | [Reflection.AssemblyName]$AssemblyName, 28 | 29 | [Boolean]$UseGlobalVariable = $true, 30 | 31 | [Switch]$PassThru 32 | ) 33 | 34 | $AppDomain = [AppDomain]::CurrentDomain 35 | 36 | # Multiple assemblies of the same name can exist. This check aborts if the assembly name exists on the assumption 37 | # that this is undesirable. 38 | $AssemblyRegEx = "^$($AssemblyName.Name -replace '\.', '\.')," 39 | if ($AppDomain.GetAssemblies() | 40 | Where-Object { 41 | $_.IsDynamic -and $_.Fullname -match $AssemblyRegEx }) { 42 | 43 | Write-Error "New-DynamicModuleBuilder: Dynamic assembly $($AssemblyName.Name) already exists." 44 | return 45 | } 46 | 47 | # Create a dynamic assembly in the current AppDomain 48 | $AssemblyBuilder = $AppDomain.DefineDynamicAssembly( 49 | $AssemblyName, 50 | [Reflection.Emit.AssemblyBuilderAccess]::Run 51 | ) 52 | 53 | $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule($AssemblyName.Name) 54 | if ($UseGlobalVariable) { 55 | # Create a transient dynamic module within the new assembly 56 | New-Variable Indented_ModuleBuilder -Scope Global -Value $ModuleBuilder 57 | if ($PassThru) { 58 | $ModuleBuilder 59 | } 60 | } else { 61 | return $ModuleBuilder 62 | } 63 | } -------------------------------------------------------------------------------- /Indented.Common/func/New-DynamicParameter.ps1: -------------------------------------------------------------------------------- 1 | function New-DynamicParameter { 2 | # .SYNOPSIS 3 | # Create a new dynamic parameter object for use with a dynamicparam block. 4 | # .DESCRIPTION 5 | # New-DynamicParameter allows simplified creation of runtime (dynamic) parameters. 6 | # .PARAMETER ParameterName 7 | # The name of the parameter to create. 8 | # .PARAMETER ParameterType 9 | # The .NET type of this parameter. 10 | # .PARAMETER Mandatory 11 | # Set the mandatory flag for this parameter. 12 | # .PARAMETER Position 13 | # Define a position for the parameter. 14 | # .PARAMETER ValueFromPipeline 15 | # The parameter can be filled from the input pipeline. 16 | # .PARAMETER ValueFromPipelineByPropertyName 17 | # The parameter can be filled from a specific property in the input pipeline. 18 | # .PARAMETER ParameterSetName 19 | # Assign the parameter to a specific parameter set. 20 | # .PARAMETER ValidateNotNullOrEmpty 21 | # Disallow null or empty values for the parameter if the parameter is specified. 22 | # .PARAMETER ValidatePattern 23 | # Test the parameter value using a regular expression. 24 | # .PARAMETER ValidatePatternOptions 25 | # Regular expression options which dictate the behaviour of ValidatePattern. 26 | # .PARAMETER ValidateRange 27 | # A minimum and maximum value to compare the argument to. 28 | # .PARAMETER ValidateScript 29 | # Test the parameter value using a script. 30 | # .PARAMETER ValidateSet 31 | # Test the parameter value against a set of values. 32 | # .PARAMETER ValidateSetIgnoreCase 33 | # ValidateSet can be configured to be case sensitive by setting this parameter to $false. The default behaviour for ValidateSet ignores case. 34 | # .INPUTS 35 | # System.Object 36 | # System.Object[] 37 | # System.String 38 | # System.Type 39 | # .OUTPUTS 40 | # System.Management.Automation.RuntimeDefinedParameter 41 | # .EXAMPLE 42 | # New-DynamicParameter Name -DefaultValue "Test" -ParameterType "String" -Mandatory -ValidateSet "Test", "Live" 43 | # .EXAMPLE 44 | # New-DynamicParameter Name -ValueFromPipelineByPropertyName 45 | # .EXAMPLE 46 | # New-DynamicParameter Name -ValidateRange 1, 2 47 | # .NOTES 48 | # Author: Chris Dent 49 | # 50 | # Change log: 51 | # 24/10/2014 - Chris Dent - Added support for ValidatePattern options and ValidateSet case sensitivity. 52 | # 22/10/2014 - Chris Dent - Created. 53 | 54 | [CmdLetBinding()] 55 | param( 56 | [Parameter(Mandatory = $true)] 57 | [ValidateNotNullOrEmpty()] 58 | [Alias('Name')] 59 | [String]$ParameterName, 60 | 61 | [Object]$DefaultValue, 62 | 63 | [Type]$ParameterType = "Object", 64 | 65 | [Switch]$Mandatory, 66 | 67 | [Int32]$Position = -2147483648, 68 | 69 | [Switch]$ValueFromPipeline, 70 | 71 | [Switch]$ValueFromPipelineByPropertyName, 72 | 73 | [String]$ParameterSetName = "__AllParameterSets", 74 | 75 | [Switch]$ValidateNotNullOrEmpty, 76 | 77 | [ValidateNotNullOrEmpty()] 78 | [RegEx]$ValidatePattern, 79 | 80 | [Text.RegularExpressions.RegexOptions]$ValidatePatternOptions = [Text.RegularExpressions.RegexOptions]::IgnoreCase, 81 | 82 | [Object[]]$ValidateRange, 83 | 84 | [ValidateNotNullOrEmpty()] 85 | [ScriptBlock]$ValidateScript, 86 | 87 | [ValidateNotNullOrEmpty()] 88 | [Object[]]$ValidateSet, 89 | 90 | [Boolean]$ValidateSetIgnoreCase = $true 91 | ) 92 | 93 | $AttributeCollection = @() 94 | 95 | $ParameterAttribute = New-Object Management.Automation.ParameterAttribute 96 | $ParameterAttribute.Mandatory = $Mandatory 97 | $ParameterAttribute.Position = $Position 98 | $ParameterAttribute.ValueFromPipeline = $ValueFromPipeline 99 | $ParameterAttribute.ValueFromPipelineByPropertyName = $ValueFromPipelineByPropertyName 100 | 101 | $AttributeCollection += $ParameterAttribute 102 | 103 | if ($psboundparameters.ContainsKey('ValidateNotNullOrEmpty')) { 104 | $AttributeCollection += New-Object Management.Automation.ValidateNotNullOrEmptyAttribute 105 | } 106 | if ($psboundparameters.ContainsKey('ValidatePattern')) { 107 | $ValidatePatternAttribute = New-Object Management.Automation.ValidatePatternAttribute($ValidatePattern.ToString()) 108 | $ValidatePatternAttribute.Options = $ValidatePatternOptions 109 | 110 | $AttributeCollection += $ValidatePatternAttribute 111 | 112 | } 113 | if ($psboundparameters.ContainsKey('ValidateRange')) { 114 | $AttributeCollection += New-Object Management.Automation.ValidateRangeAttribute($ValidateRange) 115 | } 116 | if ($psboundparameters.ContainsKey('ValidateScript')) { 117 | $AttributeCollection += New-Object Management.Automation.ValidateScriptAttribute($ValidateScript) 118 | } 119 | if ($psboundparameters.ContainsKey('ValidateSet')) { 120 | $ValidateSetAttribute = New-Object Management.Automation.ValidateSetAttribute($ValidateSet) 121 | $ValidateSetAttribute.IgnoreCase = $ValidateSetIgnoreCase 122 | 123 | $AttributeCollection += $ValidateSetAttribute 124 | } 125 | 126 | $Parameter = New-Object Management.Automation.RuntimeDefinedParameter($ParameterName, $ParameterType, $AttributeCollection) 127 | if ($psboundparameters.ContainsKey('DefaultValue')) { 128 | $Parameter.Value = $DefaultValue 129 | } 130 | return $Parameter 131 | } -------------------------------------------------------------------------------- /Indented.Common/func/New-Enum.ps1: -------------------------------------------------------------------------------- 1 | function New-Enum { 2 | # .SYNOPSIS 3 | # Creates a new enum (System.Enum) from a hashtable using an existing dynamic module. 4 | # .DESCRIPTION 5 | # New-Enum dynamically creates an enum with the specified name (and namespace). 6 | # 7 | # A hashtable is used to populate the enum. All values passed in via the hashtable must be able to convert to the enum type. 8 | # 9 | # The enum is created, but not returned by this function. 10 | # .PARAMETER Members 11 | # A hashtable describing the members of the enum. 12 | # .PARAMETER ModuleBuilder 13 | # A dynamic module within a dynamic assembly, created by New-DynamicModuleBuilder. By default, the function uses the global variable Indented_ModuleBuilder, populated if New-DynamicModuleBuilder is executed with UseGlobalVariable set to true (the default value). 14 | # .PARAMETER Name 15 | # A name for the enum, a namespace may be included. 16 | # .PARAMETER SetFlagsAttribute 17 | # Optionally sets the System.FlagsAttribute on the enum, indicating the enum can be treated as a bit field. Note that the enum members must support this attribute. 18 | # .PARAMETER Type 19 | # A .NET value type, by default Int32 is used. The type name is passed as a string and converted to a Type by the function. 20 | # .INPUTS 21 | # System.Reflection.Emit.ModuleBuilder 22 | # System.String 23 | # System.HashTable 24 | # System.Type 25 | # .EXAMPLE 26 | # C:\PS>New-DynamicModuleBuilder "Example" 27 | # C:\PS>$EnumMembers = @{cat=1;dog=2;tortoise=4;rabbit=8} 28 | # C:\PS>New-Enum -Name "Example.Pets" -SetFlagsAttribute -Members $EnumMembers 29 | # C:\PS>[Example.Pets]10 30 | # 31 | # Creates a new enumeration in memory, then returns values "dog" and "rabbit". 32 | # .EXAMPLE 33 | # C:\PS>$Builder = New-DynamicModuleBuilder "Example" -UseGlobalVariable $false 34 | # C:\PS>New-Enum -ModuleBuilder $Builder -Name "Example.Byte" ` 35 | # >> -Type "Byte" -Members @{one=1;two=2} 36 | # >> 37 | # C:\PS>[Example.Byte]2 38 | # 39 | # Uses a user-defined variable to store the created dynamic module. The example returns the value "two". 40 | # .EXAMPLE 41 | # C:\PS>New-DynamicModuleBuilder "Example" 42 | # C:\PS>New-Enum -Name "Example.NumbersLow" -Members @{One=1; Two=2} 43 | # C:\PS>New-Enum -Name "Example.NumbersHigh" -Members @{OneHundred=100; TwoHundred=200} 44 | # C:\PS>[UInt32][Example.NumbersLow]::One + [UInt32][Example.NumbersHigh]::OneHundred 45 | # 46 | # Multiple Enumerations can be built within the same dynamic assembly, a module builder only needs to be created once. 47 | # .NOTES 48 | # Author: Chris Dent 49 | # 50 | # Change log: 51 | # 17/08/2013 - Chris Dent - Created. 52 | 53 | [CmdLetBinding()] 54 | param( 55 | [Reflection.Emit.ModuleBuilder]$ModuleBuilder = $Indented_ModuleBuilder, 56 | 57 | [Parameter(Mandatory = $true, Position = 1)] 58 | [ValidatePattern('^(\w+\.)*\w+$')] 59 | [String]$Name, 60 | 61 | [Type]$Type = "Int32", 62 | 63 | [Alias('Flags')] 64 | [Switch]$SetFlagsAttribute, 65 | 66 | [Parameter(Mandatory = $true)] 67 | [HashTable]$Members 68 | ) 69 | 70 | # This function cannot overwrite or append to existing types. 71 | # Abort if a type of the same name is found and return a more friendly error than ValidateScript would. 72 | if ($Name -as [Type]) { 73 | Write-Error "New-Enum: Type $Name already exists" 74 | return 75 | } 76 | 77 | # Begin defining a public System.Enum 78 | $EnumBuilder = $ModuleBuilder.DefineEnum( 79 | $Name, 80 | [Reflection.TypeAttributes]::Public, 81 | $Type) 82 | if ($?) { 83 | if ($SetFlagsAttribute) { 84 | $EnumBuilder.SetCustomAttribute( 85 | [FlagsAttribute].GetConstructor([Type]::EmptyTypes), 86 | @() 87 | ) 88 | } 89 | $Members.Keys | ForEach-Object { 90 | $null = $EnumBuilder.DefineLiteral($_, [Convert]::ChangeType($Members[$_], $Type)) 91 | } 92 | $Enum = $EnumBuilder.CreateType() 93 | } 94 | } -------------------------------------------------------------------------------- /Indented.Common/func/New-XPathNavigator.ps1: -------------------------------------------------------------------------------- 1 | function New-XPathNavigator { 2 | # .SYNOPSIS 3 | # Create a new XPathNavigator. 4 | # .DESCRIPTION 5 | # Create a new XPathNavigator. The XML file may be opened as read-only or write. 6 | # .PARAMETER FileName 7 | # The XML file to open. 8 | # .INPUTS 9 | # System.String 10 | # .OUTPUTS 11 | # System.Xml.XPath.XPathNavigator 12 | # .EXAMPLE 13 | # New-XPathNavigator C:\Test.xml 14 | # .NOTES 15 | # Author: Chris Dent 16 | # 17 | # Change log: 18 | # 04/07/2014 - Chris Dent - Created. 19 | 20 | [CmdLetBinding()] 21 | param( 22 | [Parameter(ValueFromPipelineByPropertyName = $true)] 23 | [Alias('FullName')] 24 | [String]$FileName, 25 | 26 | [ValidateSet('ReadOnly', 'Write')] 27 | [String]$Mode = "ReadOnly" 28 | ) 29 | 30 | process { 31 | if ($FileName -and (Test-Path $FileName)) { 32 | $FileName = (Get-Item $FileName).FullName 33 | 34 | if ($Mode -eq "ReadOnly") { 35 | # Open as ReadOnly 36 | $XmlDocument = New-Object Xml.XPath.XPathDocument($FileName) 37 | } else { 38 | $XmlDocument = New-Object Xml.XmlDocument 39 | $XmlDocument.Load($FileName) 40 | } 41 | } else { 42 | $XmlDocument = New-Object Xml.XmlDocument 43 | } 44 | 45 | return $XmlDocument.CreateNavigator() 46 | } 47 | } -------------------------------------------------------------------------------- /Indented.Common/func/Set-XPathAttribute.ps1: -------------------------------------------------------------------------------- 1 | function Set-XPathAttribute { 2 | # .SYNOPSIS 3 | # Set an attribute using the XPathNavigator object. 4 | # .DESCRIPTION 5 | # Set-XPathAttribute expects an XML node iterator, the name of an attribute and the new value. 6 | # 7 | # The XML node holding the attribute must be selected before requesting a change using Set-XPathAttribute. 8 | # .PARAMETER AttributeName 9 | # The name of the attribute to set. 10 | # .PARAMETER Value 11 | # The value to set. 12 | # .PARAMETER XmlNode 13 | # An XmlNode selected using an XPathNavigator which may be created using New-XPathNavigator. 14 | # .INPUTS 15 | # System.String 16 | # System.Xml.XPath.XPathNavigator 17 | # .EXAMPLE 18 | # $XPathNavigator = New-XPathNavigator file.xml 19 | # $XmlNode = $XPathNavigator.Select("/SomeRoot/SomeElement") 20 | # Set-XPathAttribute -AttributeName "Test" -Value "NewValue" -XmlNode $XmlNode 21 | # .NOTES 22 | # Author: Chris Dent 23 | # 24 | # Change log: 25 | # 09/12/2014 - Chris Dent - Created. 26 | 27 | [CmdLetBinding()] 28 | param( 29 | [Parameter(Mandatory = $true)] 30 | [ValidateNotNullOrEmpty()] 31 | [Alias('Name')] 32 | [String]$AttributeName, 33 | 34 | [Parameter(Mandatory = $true)] 35 | [ValidateNotNullOrEmpty()] 36 | [String]$Value, 37 | 38 | [Parameter(ValueFromPipeline = $true)] 39 | [ValidateScript( { $_.PSObject.TypeNames -contains 'MS.Internal.Xml.Cache.XPathDocumentNavigator' -or $_.PSObject.TypeNames -contains 'System.Xml.DocumentXPathNavigator' } )] 40 | $XmlNode 41 | ) 42 | 43 | process { 44 | $XPathNavigator = $XmlNode.CreateNavigator() 45 | 46 | if ($XPathNavigator.GetAttribute($AttributeName, "") -ne $Value) { 47 | if ($XPathNavigator.MoveToAttribute($AttributeName, "")) { 48 | $XPathNavigator.SetValue($Value) 49 | $XPathNavigator.MoveToParent() | Out-Null 50 | } else { 51 | $XPathNavigator.CreateAttribute("", $AttributeName, "", $Value) 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Indented.Common/func/Update-PropertyOrder.ps1: -------------------------------------------------------------------------------- 1 | function Update-PropertyOrder { 2 | # .SYNOPSIS 3 | # Update the order of properties on an object. 4 | # .DESCRIPTION 5 | # Update-PropertyOrder attempts to re-order the properties on an object into alphabetical order. 6 | # 7 | # This function strips methods from the object. Type names are copied. 8 | # .PARAMETER Object 9 | # The object to re-order. 10 | # .INPUTS 11 | # System.Object 12 | # .OUTPUTS 13 | # System.Management.Automation.PSObject 14 | # .NOTES 15 | # Author: Chris Dent 16 | # 17 | # Change log: 18 | # 04/12/2014 - Chris Dent - Created. 19 | 20 | [CmdLetBinding()] 21 | param( 22 | [Parameter(ValueFromPipeline = $true)] 23 | $Object 24 | ) 25 | 26 | process { 27 | $OrderedObject = New-Object PSObject 28 | $Object | Get-Member -MemberType *Property* | Sort-Object Name | ForEach-Object { 29 | $Member = $_ 30 | switch ($_.MemberType) { 31 | 'AliasProperty' { $OrderedObject | Add-Member $Member.Name -MemberType AliasProperty -Value $Object.PSObject.Properties[$Member.Name].ReferencedMemberName; break } 32 | 'ScriptProperty' { $OrderedObject | Add-Member $Member.Name -MemberType ScriptProperty -Value $Object.PSObject.Properties[$Member.Name].GetterScript; break } 33 | default { $OrderedObject | Add-Member $Member.Name -MemberType NoteProperty -Value $Object.$($Member.Name) } 34 | } 35 | } 36 | $Object.PSObject.TypeNames | Where-Object { $_ -notin $OrderedObject.PSObject.TypeNames } | ForEach-Object { 37 | $OrderedObject.PSObject.TypeNames.Add($_) 38 | } 39 | $OrderedObject 40 | } 41 | } -------------------------------------------------------------------------------- /Indented.DnsResolver/Indented.DnsResolver.Format.ps1xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Indented.DnsResolver.Message 9 | 10 | Indented.DnsResolver.Message 11 | 12 | 13 | 14 | 15 | 16 | 17 | Header 18 | 19 | 20 | 21 | QuestionToString 22 | 23 | 24 | 25 | AnswerToString 26 | 27 | 28 | 29 | AuthorityToString 30 | 31 | 32 | 33 | AdditionalToString 34 | 35 | 36 | Server 37 | 38 | 39 | Size 40 | 41 | 42 | TimeTaken 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Indented.DnsResolver.Message.CacheRecord 52 | 53 | Indented.DnsResolver.Message.CacheRecord 54 | 55 | 56 | 57 | 58 | 59 | left 60 | 61 | 62 | 63 | left 64 | 65 | 66 | 67 | left 68 | 69 | 70 | 71 | left 72 | 73 | 74 | 75 | left 76 | 77 | 78 | 79 | 80 | 81 | 82 | Name 83 | 84 | 85 | TTL 86 | 87 | 88 | RecordType 89 | 90 | 91 | IPAddress 92 | 93 | 94 | ResourceType 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Indented.DnsResolver/Indented.DnsResolver.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/Indented.DnsResolver.psd1 -------------------------------------------------------------------------------- /Indented.DnsResolver/Indented.DnsResolver.psm1: -------------------------------------------------------------------------------- 1 | # 2 | # Module loader for Indented.DnsResolver 3 | # 4 | # Author: Chris Dent 5 | # 6 | 7 | # Static enumerations 8 | [Array]$Enum = 'Indented.DnsResolver.AFSDBSubType', 9 | 'Indented.DnsResolver.ATMAFormat', 10 | 'Indented.DnsResolver.CertificateType', 11 | 'Indented.DnsResolver.DigestType', 12 | 'Indented.DnsResolver.EDnsOptionCode', 13 | 'Indented.DnsResolver.EDnsSECOK', 14 | 'Indented.DnsResolver.EncryptionAlgorithm', 15 | 'Indented.DnsResolver.Flags', 16 | 'Indented.DnsResolver.IanaAddressFamily', 17 | 'Indented.DnsResolver.IPSECAlgorithm', 18 | 'Indented.DnsResolver.IPSECGatewayType', 19 | 'Indented.DnsResolver.KEYAC', 20 | 'Indented.DnsResolver.KEYNameType', 21 | 'Indented.DnsResolver.KEYProtocol', 22 | 'Indented.DnsResolver.LLQErrorCode', 23 | 'Indented.DnsResolver.LLQOpCode', 24 | 'Indented.DnsResolver.MessageCompression', 25 | 'Indented.DnsResolver.MSDNSOption', 26 | 'Indented.DnsResolver.NSEC3Flags', 27 | 'Indented.DnsResolver.NSEC3HashAlgorithm', 28 | 'Indented.DnsResolver.QR', 29 | 'Indented.DnsResolver.RCode', 30 | 'Indented.DnsResolver.RecordClass', 31 | 'Indented.DnsResolver.RecordType', 32 | 'Indented.DnsResolver.SSHAlgorithm', 33 | 'Indented.DnsResolver.SSHFPType', 34 | 'Indented.DnsResolver.TKEYMode', 35 | 'Indented.DnsResolver.WINSMappingFlag' 36 | 37 | if ($Enum.Count -ge 1) { 38 | New-Variable DnsResolverModuleBuilder -Value (New-DynamicModuleBuilder Indented.DnsResolver -UseGlobalVariable $false) -Scope Script 39 | $Enum | ForEach-Object { 40 | Import-Module "$psscriptroot\enum\$_.ps1" 41 | } 42 | } 43 | 44 | # Private functions 45 | [Array]$Private = 'ConvertFromDnsDomainName', 46 | 'ConvertToDnsDomainName', 47 | 'NewDnsMessage', 48 | 'NewDnsMessageHeader', 49 | 'NewDnsMessageQuestion', 50 | 'NewDnsOPTRecord', 51 | 'NewDnsSOARecord', 52 | 'ReadDnsA6Record', 53 | 'ReadDnsAAAARecord', 54 | 'ReadDnsAFSDBRecord', 55 | 'ReadDnsAPLRecord', 56 | 'ReadDnsARecord', 57 | 'ReadDnsATMARecord', 58 | 'ReadDnsCERTRecord', 59 | 'ReadDnsCharacterString', 60 | 'ReadDnsCNAMERecord', 61 | 'ReadDnsDHCIDRecord', 62 | 'ReadDnsDLVRecord', 63 | 'ReadDnsDNAMERecord', 64 | 'ReadDnsDNSKEYRecord', 65 | 'ReadDnsDSRecord', 66 | 'ReadDnsEIDRecord', 67 | 'ReadDnsGPOSRecord', 68 | 'ReadDnsHINFORecord', 69 | 'ReadDnsHIPRecord', 70 | 'ReadDnsIPSECKEYRecord', 71 | 'ReadDnsISDNRecord', 72 | 'ReadDnsKEYRecord', 73 | 'ReadDnsKXRecord', 74 | 'ReadDnsLOCRecord', 75 | 'ReadDnsMBRecord', 76 | 'ReadDnsMDRecord', 77 | 'ReadDnsMessage', 78 | 'ReadDnsMessageHeader', 79 | 'ReadDnsMessageQuestion', 80 | 'ReadDnsMFRecord', 81 | 'ReadDnsMGRecord', 82 | 'ReadDnsMINFORecord', 83 | 'ReadDnsMRRecord', 84 | 'ReadDnsMXRecord', 85 | 'ReadDnsNAPTRRecord', 86 | 'ReadDnsNINFORecord', 87 | 'ReadDnsNSAPRecord', 88 | 'ReadDnsNSEC3PARAMRecord', 89 | 'ReadDnsNSEC3Record', 90 | 'ReadDnsNSECRecord', 91 | 'ReadDnsNSRecord', 92 | 'ReadDnsNULLRecord', 93 | 'ReadDnsNXTRecord', 94 | 'ReadDnsOPTRecord', 95 | 'ReadDnsPTRRecord', 96 | 'ReadDnsPXRecord', 97 | 'ReadDnsResourceRecord', 98 | 'ReadDnsRKEYRecord', 99 | 'ReadDnsRPRecord', 100 | 'ReadDnsRRSIGRecord', 101 | 'ReadDnsRTRecord', 102 | 'ReadDnsSIGRecord', 103 | 'ReadDnsSINKRecord', 104 | 'ReadDnsSOARecord', 105 | 'ReadDnsSPFRecord', 106 | 'ReadDnsSRVRecord', 107 | 'ReadDnsSSHFPPRecord', 108 | 'ReadDnsTARecord', 109 | 'ReadDnsTKEYRecord', 110 | 'ReadDnsTSIGRecord', 111 | 'ReadDnsTXTRecord', 112 | 'ReadDnsUnknownRecord', 113 | 'ReadDnsWINSRecord', 114 | 'ReadDnsWINSRRecord', 115 | 'ReadDnsWKSRecord', 116 | 'ReadDnsX25Record' 117 | 118 | if ($Private.Count -ge 1) { 119 | $Private | ForEach-Object { 120 | Import-Module "$psscriptroot\func-priv\$_.ps1" 121 | } 122 | } 123 | 124 | # Public functions 125 | [Array]$Public = 'Add-InternalDnsCacheRecord', 126 | 'Get-Dns', 127 | 'Get-DnsServerList', 128 | 'Get-InternalDnsCacheRecord', 129 | 'Initialize-InternalDnsCache', 130 | 'Remove-InternalDnsCacheRecord', 131 | 'Update-InternalRootHints' 132 | 133 | if ($Public.Count -ge 1) { 134 | $Public | ForEach-Object { 135 | Import-Module "$psscriptroot\func\$_.ps1" 136 | } 137 | } 138 | 139 | # Resolver (Message): Initialize the DNS cache for Get-Dns 140 | Initialize-InternalDnsCache 141 | 142 | # Resolver (Message): Set a variable to store TC state. 143 | New-Variable DnsTCEndFound -Scope Script -Value $false 144 | 145 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.AFSDBSubType.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.AFSDBSubType" -Type "UInt16" -Members @{ 2 | AFSv3Loc = 1; # Andrews File Service v3.0 Location Service [RFC1183] 3 | DCENCARoot = 2; # DCE/NCA root cell directory node [RFC1183] 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.ATMAFormat.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.ATMAFormat" -Type "UInt16" -Members @{ 2 | AESA = 0; # ATM End System Address 3 | E164 = 1; # E.164 address format 4 | NSAP = 2; # Network Service Access Protocol (NSAP) address model 5 | } 6 | 7 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.CertificateType.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.CertificateType" -Type "UInt16" -Members @{ 2 | PKIX = 1; # X.509 as per PKIX 3 | SPKI = 2; # SPKI certificate 4 | PGP = 3; # OpenPGP packet 5 | IPKIX = 4; # The URL of an X.509 data object 6 | ISPKI = 5; # The URL of an SPKI certificate 7 | IPGP = 6; # The fingerprint and URL of an OpenPGP packet 8 | ACPKIX = 7; # Attribute Certificate 9 | IACPKIX = 8; # The URL of an Attribute Certificate 10 | URI = 253; # URI private 11 | OID = 254; # OID private 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.DigestType.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.DigestType" -Type "Byte" -Members @{ 2 | SHA1 = 1; # MANDATORY [RFC3658] 3 | SHA256 = 2; # MANDATORY [RFC4059] 4 | GOST = 3; # OPTIONAL [RFC5933] 5 | SHA384 = 4; # OPTIONAL [RFC6605] 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.EDnsOptionCode.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.EDnsOptionCode" -Type "UInt16" -Members @{ 2 | LLQ = 1; # On-hold [http://files.dns-sd.org/draft-sekar-dns-llq.txt] 3 | UL = 2; # On-hold [http://files.dns-sd.org/draft-sekar-dns-ul.txt] 4 | NSID = 3; # Standard [RFC5001] 5 | DAU = 5; # Standard [RFC6975] 6 | DHU = 6; # Standard [RFC6975] 7 | N3U = 7; # Standard [RFC6975] 8 | "EDNS-client-subnet" = 8; # Optional [draft-vandergaast-edns-client-subnet][Wilmer_van_der_Gaast] 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.EDnsSECOK.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.EDnsDNSSECOK" -Type "UInt16" -SetFlagsAttribute -Members @{ 2 | NONE = 0; 3 | DO = 32768; # DNSSEC answer OK [RFC4035][RFC3225] 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.EncryptionAlgorithm.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.EncryptionAlgorithm" -Type "Byte" -Members @{ 2 | RSAMD5 = 1; # RSA/MD5 (deprecated, see 5) [RFC3110][RFC4034] 3 | DH = 2; # Diffie-Hellman [RFC2539] 4 | DSA = 3; # DSA/SHA1 [RFC3755] 5 | RSASHA1 = 5; # RSA/SHA-1 [RFC3110][RFC4034] 6 | "DSA-NSEC3-SHA1" = 6; # DSA-NSEC3-SHA1 [RFC5155] 7 | "RSASHA1-NSEC3-SHA1" = 7; # RSASHA1-NSEC3-SHA1 [RFC5155] 8 | RSASHA256 = 8; # RSA/SHA-256 [RFC5702] 9 | RSASHA512 = 10; # RSA/SHA-512 [RFC5702] 10 | "ECC-GOST" = 12; # GOST R 34.10-2001 [RFC5933] 11 | ECDSAP256SHA256 = 13; # ECDSA Curve P-256 with SHA-256 [RFC6605] 12 | ECDSAP384SHA384 = 14; # ECDSA Curve P-384 with SHA-384 [RFC6605] 13 | INDIRECT = 252; # Reserved for indirect keys [RFC4034] 14 | PRIVATEDNS = 253; # Private algorithm [RFC4034] 15 | PRIVATEOID = 254; # Private algorithm OID [RFC4034] 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.Flags.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.Flags" -Type "UInt16" -SetFlagsAttribute -Members @{ 2 | None = 0; 3 | AA = 1024; # Authoritative Answer [RFC1035] 4 | TC = 512; # Truncated Response [RFC1035] 5 | RD = 256; # Recursion Desired [RFC1035] 6 | RA = 128; # Recursion Allowed [RFC1035] 7 | AD = 32; # Authenticated Data [RFC4035] 8 | CD = 16; # Checking Disabled [RFC4035] 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.IPSECAlgorithm.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.IPSECAlgorithm" -Type "Byte" -Members @{ 2 | DSA = 1; # [RFC4025] 3 | RSA = 2; # [RFC4025] 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.IPSECGatewayType.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.IPSECGatewayType" -Type "Byte" -Members @{ 2 | NoGateway = 0; # No gateway is present [RFC4025] 3 | IPv4 = 1; # A 4-byte IPv4 address is present [RFC4025] 4 | IPv6 = 2; # A 16-byte IPv6 address is present [RFC4025] 5 | DomainName = 3; # A wire-encoded domain name is present [RFC4025] 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.IanaAddressFamily.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.IanaAddressFamily" -Type "UInt16" -Members @{ 2 | IPv4 = 1; # IP version 4 3 | IPv6 = 2; # IP version 6 4 | NSAP = 3; # NSAP 5 | HDLC = 4; # HDLC (8-bit multidrop) 6 | BBN = 5; # BBN 1822 7 | "802" = 6; # 802 (includes all 802 media plus Ethernet "canonical format") 8 | "E.163" = 7; # E.163 9 | "E.164" = 8; # E.164 (SMDS, Frame Relay, ATM) 10 | "F.69" = 9; # F.69 (Telex) 11 | "X.121" = 10; # X.121 (X.25, Frame Relay) 12 | IPX = 11; # IPX 13 | Appletalk = 12; # Appletalk 14 | DecNetIV = 13; # DecNet IV 15 | BanyanVines = 14; # Banyan Vines 16 | "E.164NSAP" = 15; # E.164 with NSAP format subaddress [ATM Forum UNI 3.1. October 1995.][Andy_Malis] 17 | DNS = 16; # DNS (Domain Name System) 18 | DistinguishedName = 17; # Distinguished Name [Charles_Lynn] 19 | ASNumber = 18; # AS Number [Charles_Lynn] 20 | XTPOverIpv4 = 19; # XTP over IP version 4 [Mike_Saul] 21 | XTPOverIPv6 = 20; # XTP over IP version 6 [Mike_Saul] 22 | XTPNativeMode = 21; # XTP native mode XTP [Mike_Saul] 23 | FibreChannelWWPortName = 22; # Fibre Channel World-Wide Port Name [Mark_Bakke] 24 | FibreChannelWWNodeName = 23; # Fibre Channel World-Wide Node Name [Mark_Bakke] 25 | GWID = 24; # GWID [Subra_Hegde] 26 | AFIForL2VPN = 25; # AFI for L2VPN information [RFC4761][RFC6074] 27 | MPLSTPSectionID = 26; # MPLS-TP Section Endpoint Identifier [RFC-ietf-mpls-gach-adv-08] 28 | MPLSTPLSPID = 27; # MPLS-TP LSP Endpoint Identifier [RFC-ietf-mpls-gach-adv-08] 29 | MPLSTPPseudowireID = 28; # MPLS-TP Pseudowire Endpoint Identifier [RFC-ietf-mpls-gach-adv-08] 30 | EIGRPCommon = 16384; # EIGRP Common Service Family [Donnie_Savage] 31 | EIGRPIPv4 = 16385; # EIGRP IPv4 Service Family [Donnie_Savage] 32 | EIGRPIPv6 = 16386; # EIGRP IPv6 Service Family [Donnie_Savage] 33 | LCAF = 16387; # LISP Canonical Address Format (LCAF) [David_Meyer] 34 | BGPLS = 16388; # BGP-LS [draft-ietf-idr-ls-distribution] 35 | MAC48bit = 16389; # 48-bit MAC [RFC-eastlake-rfc5342bis-05] 36 | MAC64bit = 16390; # 64-bit MAC [RFC-eastlake-rfc5342bis-05] 37 | OUI = 16391; # OUI [draft-eastlake-trill-ia-appsubtlv] 38 | MAC24 = 16392; # MAC/24 [draft-eastlake-trill-ia-appsubtlv] 39 | MAC40 = 16393; # MAC/40 [draft-eastlake-trill-ia-appsubtlv] 40 | "IPv6-64" = 16394; # IPv6/64 [draft-eastlake-trill-ia-appsubtlv] 41 | RBridgePortID = 16395; # RBridge Port ID [draft-eastlake-trill-ia-appsubtlv] 42 | } 43 | 44 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.KEYAC.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.KEYAC" -Type "Byte" -Members @{ 2 | AuthAndConfPermitted = 0; # Use of the key for authentication and/or confidentiality is permitted. 3 | AuthProhibited = 2; # Use of the key is prohibited for authentication. 4 | ConfProhibited = 1; # Use of the key is prohibited for confidentiality. 5 | NoKey = 3; # No key information 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.KEYNameType.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.KEYNameType" -Type "Byte" -Members @{ 2 | UserKey = 0; # Indicates that this is a key associated with a "user" or "account" at an end entity, usually a host. 3 | ZoneKey = 1; # Indicates that this is a zone key for the zone whose name is the KEY RR owner name. 4 | NonZone = 2; # Indicates that this is a key associated with the non-zone "entity" whose name is the RR owner name. 5 | Reserved = 3; # Reserved 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.KEYProtocol.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.KEYProtocol" -Type "Byte" -Members @{ 2 | Reserved = 0; 3 | TLS = 1; 4 | EMmail = 2; 5 | DNSSEC = 3; 6 | IPSEC = 4; 7 | All = 255; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.LLQErrorCode.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.LLQErrorCode" -Type "UInt16" -Members @{ 2 | NoError = 0; 3 | ServFull = 1; 4 | Static = 2; 5 | FormatErr = 3; 6 | NoSuchLLQ = 4; 7 | BadVers = 5; 8 | UnknownErr = 6; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.LLQOpCode.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.LLQOpCode" -Type "UInt16" -Members @{ 2 | LLQSetup = 1; 3 | LLQRefresh = 2; 4 | LLQEvent = 3; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.MSDNSOption.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.OpCode" -Type "UInt16" -Members @{ 2 | Query = 0; # [RFC1035] 3 | IQuery = 1; # [RFC3425] 4 | Status = 2; # [RFC1035] 5 | Notify = 4; # [RFC1996] 6 | Update = 5; # [RFC2136] 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.MessageCompression.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.MessageCompression" -Type "Byte" -Members @{ 2 | Enabled = 192; 3 | Disabled = 0; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.NSEC3Flags.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.NSEC3Flags" -Type "Byte" -Members @{ 2 | OptOut = 1; # [RFC5155] 3 | } 4 | 5 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.NSEC3HashAlgorithm.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.NSEC3HashAlgorithm" -Type "Byte" -Members @{ 2 | SHA1 = 1; # [RFC5155] 3 | } 4 | 5 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.QR.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.QR" -Type "UInt16" -Members @{ 2 | Query = 0; 3 | Response = 32768 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.RCode.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.RCode" -Type "UInt16" -Members @{ 2 | NoError = 0; # No Error [RFC1035] 3 | FormErr = 1; # Format Error [RFC1035] 4 | ServFail = 2; # Server Failure [RFC1035] 5 | NXDomain = 3; # Non-Existent Domain [RFC1035] 6 | NotImp = 4; # Not Implemented [RFC1035] 7 | Refused = 5; # Query Refused [RFC1035] 8 | YXDomain = 6; # Name Exists when it should not [RFC2136] 9 | YXRRSet = 7; # RR Set Exists when it should not [RFC2136] 10 | NXRRSet = 8; # RR Set that should exist does not [RFC2136] 11 | NotAuth = 9; # Server Not Authoritative for zone [RFC2136] 12 | NotZone = 10; # Name not contained in zone [RFC2136] 13 | BadVers = 16; # Bad OPT Version [RFC2671] 14 | BadSig = 16; # TSIG Signature Failure [RFC2845] 15 | BadKey = 17; # Key not recognized [RFC2845] 16 | BadTime = 18; # Signature out of time window [RFC2845] 17 | BadMode = 19; # Bad TKEY Mode [RFC2930] 18 | BadName = 20; # Duplicate key name [RFC2930] 19 | BadAlg = 21; # Algorithm not supported [RFC2930] 20 | BadTrunc = 22; # Bad Truncation [RFC4635] 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.RecordClass.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.RecordClass" -Type "UInt16" -Members @{ 2 | IN = 1; # [RFC1035] 3 | CH = 3; # [Moon1981] 4 | HS = 4; # [Dyer1987] 5 | NONE = 254; # [RFC2136] 6 | ANY = 255; # [RFC1035] 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.RecordType.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.RecordType" -Type "UInt16" -Members @{ 2 | EMPTY = 0; # an empty record [RFC1034] [MS DNS] 3 | A = 1; # a host address [RFC1035] 4 | NS = 2; # an authoritative name server [RFC1035] 5 | MD = 3; # a mail destination (Obsolete - use MX) [RFC1035] 6 | MF = 4; # a mail forwarder (Obsolete - use MX) [RFC1035] 7 | CNAME = 5; # the canonical name for an alias [RFC1035] 8 | SOA = 6; # marks the start of a zone of authority [RFC1035] 9 | MB = 7; # a mailbox domain name (EXPERIMENTAL) [RFC1035] 10 | MG = 8; # a mail group member (EXPERIMENTAL) [RFC1035] 11 | MR = 9; # a mail rename domain name (EXPERIMENTAL) [RFC1035] 12 | NULL = 10; # a null RR (EXPERIMENTAL) [RFC1035] 13 | WKS = 11; # a well known service description [RFC1035] 14 | PTR = 12; # a domain name pointer [RFC1035] 15 | HINFO = 13; # host information [RFC1035] 16 | MINFO = 14; # mailbox or mail list information [RFC1035] 17 | MX = 15; # mail exchange [RFC1035] 18 | TXT = 16; # text strings [RFC1035] 19 | RP = 17; # for Responsible Person [RFC1183] 20 | AFSDB = 18; # for AFS Data Base location [RFC1183] 21 | X25 = 19; # for X.25 PSDN address [RFC1183] 22 | ISDN = 20; # for ISDN address [RFC1183] 23 | RT = 21; # for Route Through [RFC1183] 24 | NSAP = 22; # for NSAP address; NSAP style A record [RFC1706] 25 | NSAPPTR = 23; # for domain name pointer; NSAP style [RFC1348] 26 | SIG = 24; # for security signature [RFC4034][RFC3755][RFC2535] 27 | KEY = 25; # for security key [RFC4034][RFC3755][RFC2535] 28 | PX = 26; # X.400 mail mapping information [RFC2163] 29 | GPOS = 27; # Geographical Position [RFC1712] 30 | AAAA = 28; # IP6 Address [RFC3596] 31 | LOC = 29; # Location Information [RFC1876] 32 | NXT = 30; # Next Domain - OBSOLETE [RFC3755][RFC2535] 33 | EID = 31; # Endpoint Identifier [Patton] 34 | NIMLOC = 32; # Nimrod Locator [Patton] 35 | SRV = 33; # Server Selection [RFC2782] 36 | ATMA = 34; # ATM Address [ATMDOC] 37 | NAPTR = 35; # Naming Authority Pointer [RFC2915][RFC2168] 38 | KX = 36; # Key Exchanger [RFC2230] 39 | CERT = 37; # CERT [RFC4398] 40 | A6 = 38; # A6 (Experimental) [RFC3226][RFC2874] 41 | DNAME = 39; # DNAME [RFC2672] 42 | SINK = 40; # SINK [Eastlake] 43 | OPT = 41; # OPT [RFC2671] 44 | APL = 42; # APL [RFC3123] 45 | DS = 43; # Delegation Signer [RFC4034][RFC3658] 46 | SSHFP = 44; # SSH Key Fingerprint [RFC4255] 47 | IPSECKEY = 45; # IPSECKEY [RFC4025] 48 | RRSIG = 46; # RRSIG [RFC4034][RFC3755] 49 | NSEC = 47; # NSEC [RFC4034][RFC3755] 50 | DNSKEY = 48; # DNSKEY [RFC4034][RFC3755] 51 | DHCID = 49; # DHCID [RFC4701] 52 | NSEC3 = 50; # NSEC3 [RFC5155] 53 | NSEC3PARAM = 51; # NSEC3PARAM [RFC5155] 54 | HIP = 55; # Host Identity Protocol [RFC5205] 55 | NINFO = 56; # NINFO [Reid] 56 | RKEY = 57; # RKEY [Reid] 57 | SPF = 99; # [RFC4408] 58 | UINFO = 100; # [IANA-Reserved] 59 | UID = 101; # [IANA-Reserved] 60 | GID = 102; # [IANA-Reserved] 61 | UNSPEC = 103; # [IANA-Reserved] 62 | TKEY = 249; # Transaction Key [RFC2930] 63 | TSIG = 250; # Transaction Signature [RFC2845] 64 | IXFR = 251; # incremental transfer [RFC1995] 65 | AXFR = 252; # transfer of an entire zone [RFC1035] 66 | MAILB = 253; # mailbox-related RRs (MB; MG or MR) [RFC1035] 67 | MAILA = 254; # mail agent RRs (Obsolete - see MX) [RFC1035] 68 | ANY = 255; # A request for all records (*) [RFC1035] 69 | TA = 32768; # DNSSEC Trust Authorities [Weiler] 2005-12-13 70 | DLV = 32769; # DNSSEC Lookaside Validation [RFC4431] 71 | WINS = 65281; # WINS records (WINS Lookup record) [MS DNS] 72 | WINSR = 65282; # WINSR records (WINS Reverse Lookup record) [MS DNS] 73 | } 74 | 75 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.SSHAlgorithm.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.SSHAlgorithm" -Type "Byte" -Members @{ 2 | RSA = 1; # [RFC4255] 3 | DSS = 2; # [RFC4255] 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.SSHFPType.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.SSHFPType" -Type "Byte" -Members @{ 2 | SHA1 = 1; # [RFC4255] 3 | } 4 | 5 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.TKEYMode.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.TKEYMode" -Type "UInt16" -Members @{ 2 | ServerAssignment = 1; # Server assignment [RFC2930] 3 | DH = 2; # Diffie-Hellman Exchange [RFC2930] 4 | GSSAPI = 3; # GSS-API negotiation [RFC2930] 5 | ResolverAssignment = 4; # Resolver assignment [RFC2930] 6 | KeyDeletion = 5; # Key deletion [RFC2930] 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Indented.DnsResolver/enum/Indented.DnsResolver.WINSMappingFlag.ps1: -------------------------------------------------------------------------------- 1 | New-Enum -ModuleBuilder $DnsResolverModuleBuilder -Name "Indented.DnsResolver.WINSMappingFlag" -Type "UInt32" -Members @{ 2 | Replication = 0; 3 | NoReplication = 65536; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ConvertFromDnsDomainName.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ConvertFromDnsDomainName.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ConvertToDnsDomainName.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ConvertToDnsDomainName.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/NewDnsMessage.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/NewDnsMessage.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/NewDnsMessageHeader.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/NewDnsMessageHeader.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/NewDnsMessageQuestion.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/NewDnsMessageQuestion.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/NewDnsOPTRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/NewDnsOPTRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/NewDnsSOARecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/NewDnsSOARecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsA6Record.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsA6Record.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsAAAARecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsAAAARecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsAFSDBRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsAFSDBRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsAPLRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsAPLRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsARecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsARecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsATMARecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsATMARecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsCERTRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsCERTRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsCNAMERecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsCNAMERecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsCharacterString.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsCharacterString.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsDHCIDRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsDHCIDRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsDLVRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsDLVRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsDNAMERecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsDNAMERecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsDNSKEYRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsDNSKEYRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsDSRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsDSRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsEIDRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsEIDRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsGPOSRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsGPOSRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsHINFORecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsHINFORecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsHIPRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsHIPRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsIPSECKEYRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsIPSECKEYRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsISDNRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsISDNRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsKEYRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsKEYRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsKXRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsKXRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsLOCRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsLOCRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMBRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMBRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMDRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMDRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMFRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMFRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMGRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMGRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMINFORecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMINFORecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMRRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMRRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMXRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMXRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMessage.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMessage.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMessageHeader.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMessageHeader.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsMessageQuestion.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsMessageQuestion.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNAPTRRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNAPTRRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNIMLOCRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNIMLOCRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNINFORecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNINFORecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNSAPRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNSAPRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNSAPTRRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNSAPTRRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNSEC3PARAMRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNSEC3PARAMRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNSEC3Record.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNSEC3Record.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNSECRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNSECRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNSRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNSRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNULLRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNULLRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsNXTRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsNXTRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsOPTRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsOPTRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsPTRRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsPTRRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsPXRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsPXRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsRKEYRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsRKEYRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsRPRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsRPRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsRRSIGRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsRRSIGRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsRTRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsRTRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsResourceRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsResourceRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsSIGRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsSIGRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsSINKRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsSINKRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsSOARecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsSOARecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsSPFRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsSPFRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsSRVRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsSRVRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsSSHFPPRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsSSHFPPRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsTARecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsTARecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsTKEYRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsTKEYRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsTSIGRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsTSIGRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsTXTRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsTXTRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsUnknownRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsUnknownRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsWINSRRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsWINSRRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsWINSRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsWINSRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsWKSRecord.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsWKSRecord.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func-priv/ReadDnsX25Record.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.DnsResolver/func-priv/ReadDnsX25Record.ps1 -------------------------------------------------------------------------------- /Indented.DnsResolver/func/Add-InternalDnsCacheRecord.ps1: -------------------------------------------------------------------------------- 1 | function Add-InternalDnsCacheRecord { 2 | # .SYNOPSIS 3 | # Add a new CacheRecord to the DNS cache object. 4 | # .DESCRIPTION 5 | # Cache records must expose the following property members: 6 | # 7 | # - Name 8 | # - TTL 9 | # - RecordType 10 | # - IPAddress 11 | # 12 | # .PARAMETER CacheRecord 13 | # A record to add to the cache. 14 | # .PARAMETER Permanent 15 | # A time property is used to age entries out of the cache. If permanent is set the time is not, the value will not be purged based on the TTL. 16 | # .INPUTS 17 | # Indented.DnsResolver.Message.CacheRecord 18 | # .EXAMPLE 19 | # $CacheRecord | Add-InternalDnsCacheRecord 20 | # .NOTES 21 | # Author: Chris Dent 22 | # 23 | # Change log: 24 | # 07/04/2015 - Chris Dent - BugFix: Type check for CacheRecord. 25 | # 13/01/2015 - Chris Dent - Forked from source module. 26 | 27 | [CmdLetBinding(DefaultParameterSetName = 'CacheRecord')] 28 | param( 29 | [Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'CacheRecord')] 30 | [ValidateScript( { $_.PsObject.TypeNames -contains 'Indented.DnsResolver.Message.CacheRecord' } )] 31 | $CacheRecord, 32 | 33 | [Parameter(Mandatory = $true, ParameterSetName = 'ResourceRecord')] 34 | [ValidateScript( { $_.PsObject.TypeNames -contains 'Indented.DnsResolver.Message.ResourceRecord' } )] 35 | $ResourceRecord, 36 | 37 | [ValidateSet("Address", "Hint")] 38 | [String]$ResourceType = "Address", 39 | 40 | [Switch]$Permanent 41 | ) 42 | 43 | begin { 44 | if (-not $Permanent) { 45 | $Time = Get-Date 46 | } 47 | } 48 | 49 | process { 50 | if ($ResourceRecord) { 51 | $TempObject = $ResourceRecord | Select-Object Name, TTL, RecordType, IPAddress 52 | $TempObject.PsObject.TypeNames.Add('Indented.DnsResolver.Message.CacheRecord') 53 | $CacheRecord = $TempObject 54 | } 55 | 56 | $CacheRecord | Add-Member ResourceType -MemberType NoteProperty -Value $ResourceType 57 | $CacheRecord | Add-Member Time -MemberType NoteProperty -Value $Time 58 | $CacheRecord | Add-Member Status -MemberType ScriptProperty -Value { 59 | if ($this.Time) { 60 | if ($this.Time.AddSeconds($this.TTL) -lt (Get-Date)) { 61 | "Expired" 62 | } else { 63 | "Active" 64 | } 65 | } else { 66 | "Permanent" 67 | } 68 | } 69 | 70 | if ($DnsCache.Contains($CacheRecord.Name)) { 71 | # Add the record to the cache if it doesn't already exist. 72 | if (-not ($CacheRecord | Get-InternalDnsCacheRecord)) { 73 | $DnsCache[$CacheRecord.Name] += $CacheRecord 74 | } 75 | } else { 76 | $DnsCache.Add($CacheRecord.Name, @($CacheRecord)) 77 | if (-not ($DnsCacheReverse.Contains($CacheRecord.IPAddress))) { 78 | $DnsCacheReverse.Add($CacheRecord.IPAddress, $CacheRecord.Name) 79 | } 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /Indented.DnsResolver/func/Get-DnsServerList.ps1: -------------------------------------------------------------------------------- 1 | function Get-DnsServerList { 2 | # .SYNOPSIS 3 | # Gets a list of network interfaces and attempts to return a list of DNS server IP addresses. 4 | # .DESCRIPTION 5 | # Get-DnsServerList uses System.Net.NetworkInformation to return a list of operational ethernet or wireless interfaces. IP properties are returned, and an attempt to return a list of DNS server addresses is made. If successful, the DNS server list is returned. 6 | # .OUTPUTS 7 | # System.Net.IPAddress[] 8 | # .EXAMPLE 9 | # Get-DnsServerList 10 | # .EXAMPLE 11 | # Get-DnsServerList -IPv6 12 | # .NOTES 13 | # Author: Chris Dent 14 | # 15 | # Change log: 16 | # 04/09/2012 - Chris Dent - Created. 17 | 18 | [CmdLetBinding()] 19 | param( 20 | [Switch]$IPv6 21 | ) 22 | 23 | if ($IPv6) { 24 | $AddressFamily = [Net.Sockets.AddressFamily]::InterNetworkv6 25 | } else { 26 | $AddressFamily = [Net.Sockets.AddressFamily]::InterNetwork 27 | } 28 | 29 | if ([Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable()) { 30 | [Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() | 31 | Where-Object { $_.OperationalStatus -eq 'Up' -and $_.NetworkInterfaceType -match 'Ethernet|Wireless' } | 32 | ForEach-Object { $_.GetIPProperties() } | 33 | Select-Object -ExpandProperty DnsAddresses -Unique | 34 | Where-Object AddressFamily -eq $AddressFamily 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Indented.DnsResolver/func/Get-InternalDnsCacheRecord.ps1: -------------------------------------------------------------------------------- 1 | function Get-InternalDnsCacheRecord { 2 | # .SYNOPSIS 3 | # Get the content of the internal DNS cache used by Get-Dns. 4 | # .DESCRIPTION 5 | # Get-InternalDnsCacheRecord displays records held in the cache. 6 | # .INPUTS 7 | # Indented.DnsResolver.RecordType 8 | # System.Net.IPAddress 9 | # System.String 10 | # .OUTPUTS 11 | # Indented.DnsResolver.Message.CacheRecord 12 | # .EXAMPLE 13 | # Get-InternalDnsCacheRecord 14 | # .EXAMPLE 15 | # Get-InternalDnsCacheRecord a.root-servers.net A 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 13/01/2015 - Chris Dent - Forked from source module. 21 | 22 | [CmdLetBinding()] 23 | param( 24 | [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)] 25 | [String]$Name, 26 | 27 | [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)] 28 | [Indented.DnsResolver.RecordType]$RecordType, 29 | 30 | [Parameter(ValueFromPipelineByPropertyName = $true)] 31 | [IPAddress]$IPAddress, 32 | 33 | [ValidateSet("Address", "Hint")] 34 | [String]$ResourceType 35 | ) 36 | 37 | process { 38 | $WhereStatementText = '$_' 39 | if ($ResourceType) { 40 | $WhereStatementText = $WhereStatementText + ' -and $_.ResourceType -eq $ResourceType' 41 | } 42 | if ($RecordType) { 43 | $WhereStatementText = $WhereStatementText + ' -and $_.RecordType -eq $RecordType' 44 | } 45 | if ($IPAddress) { 46 | $WhereStatementText = $WhereStatementText + ' -and $_.IPAddress -eq $IPAddress' 47 | } 48 | # Create a ScriptBlock using the statements above. 49 | $WhereStatement = [ScriptBlock]::Create($WhereStatementText) 50 | 51 | if ($Name) { 52 | if (-not $Name.EndsWith('.')) { 53 | $Name = "$Name." 54 | } 55 | if ($DnsCache.Contains($Name)) { 56 | $DnsCache[$Name] | Where-Object $WhereStatement 57 | } 58 | } else { 59 | # Each key may contain multiple values. Forcing a pass through ForEach-Object will 60 | # remove the multi-dimensional aspect of the return value. 61 | $DnsCache.Values | ForEach-Object { $_ } | Where-Object $WhereStatement 62 | } 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /Indented.DnsResolver/func/Initialize-InternalDnsCache.ps1: -------------------------------------------------------------------------------- 1 | function Initialize-InternalDnsCache { 2 | # .SYNOPSIS 3 | # Initializes a basic DNS cache for use by Get-Dns. 4 | # .DESCRIPTION 5 | # Get-Dns maintains a limited DNS cache, capturing A and AAAA records, to assist name server resolution (for values passed using the Server parameter). 6 | # 7 | # The cache may be manipulated using *-InternalDnsCacheRecord CmdLets. 8 | # .EXAMPLE 9 | # Initialize-InternalDnsCache 10 | # .NOTES 11 | # Author: Chris Dent 12 | # 13 | # Change log: 14 | # 08/01/2014 - Chris Dent - Released. 15 | 16 | [CmdLetBinding()] 17 | param( ) 18 | 19 | # These two variables are consumed by all other -InternalDnsCacheRecord CmdLets. 20 | 21 | # The primary cache variable stores a stub resource record 22 | if (Get-Variable DnsCache -Scope Script -ErrorAction SilentlyContinue) { 23 | Remove-Variable DnsCache -Scope Script 24 | } 25 | New-Variable DnsCache -Scope Script -Value @{} 26 | 27 | # Allows quick, if limited, reverse lookups against the cache. 28 | if (Get-Variable DnsCacheReverse -Scope Script -ErrorAction SilentlyContinue) { 29 | Remove-Variable DnsCache -Scope Script 30 | } 31 | New-Variable DnsCacheReverse -Scope Script -Value @{} 32 | 33 | if (Test-Path $psscriptroot\..\var\named.root) { 34 | Get-Content $psscriptroot\..\var\named.root | 35 | Where-Object { $_ -match '(?\S+)\s+(?\d+)\s+(IN\s+)?(?A\s+|AAAA\s+)(?\S+)' } | 36 | ForEach-Object { 37 | $CacheRecord = New-Object PsObject -Property ([Ordered]@{ 38 | Name = $matches.Name; 39 | TTL = [UInt32]$matches.TTL; 40 | RecordType = [Indented.DnsResolver.RecordType]$matches.RecordType; 41 | IPAddress = [IPAddress]$matches.IPAddress; 42 | }) 43 | $CacheRecord.PsObject.TypeNames.Add('Indented.DnsResolver.Message.CacheRecord') 44 | $CacheRecord 45 | } | 46 | Add-InternalDnsCacheRecord -Permanent -ResourceType Hint 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Indented.DnsResolver/func/Remove-InternalDnsCacheRecord.ps1: -------------------------------------------------------------------------------- 1 | function Remove-InternalDnsCacheRecord { 2 | # .SYNOPSIS 3 | # Remove an entry from the DNS cache object. 4 | # .DESCRIPTION 5 | # Remove-InternalDnsCacheRecord allows the removal of individual records from the cache, or removal of all records which expired. 6 | # .PARAMETER CacheRecord 7 | # A record to add to the cache. 8 | # .PARAMETER Permanent 9 | # A time property is used to age entries out of the cache. If permanent is set the time is not, the value will not be purged based on the TTL. 10 | # .INPUTS 11 | # Indented.DnsResolver.RecordType 12 | # System.Net.IPAddress 13 | # System.String 14 | # .EXAMPLE 15 | # Get-InternalDnsCacheRecord a.root-servers.net | Remove-InternalDnsCacheRecord 16 | # .EXAMPLE 17 | # Remove-InternalDnsCacheRecord -AllExpired 18 | # .NOTES 19 | # Author: Chris Dent 20 | # 21 | # Change log: 22 | # 28/04/2014 - Chris Dent - Released. 23 | 24 | [CmdLetBinding(DefaultParameterSetName = 'CacheRecord')] 25 | param( 26 | [Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'CacheRecord')] 27 | [ValidateScript( { $_.PsObject.TypeNames -contains 'Indented.DnsResolver.Message.CacheRecord' } )] 28 | $CacheRecord, 29 | 30 | [Parameter(Mandatory = $true, ParameterSetName = 'AllExpired')] 31 | [Switch]$AllExpired 32 | ) 33 | 34 | begin { 35 | if ($AllExpired) { 36 | $ExpiredRecords = Get-InternalDnsCacheRecord | Where-Object { $_.Status -eq 'Expired' } 37 | $ExpiredRecords | Remove-InternalDnsCacheRecord 38 | } 39 | } 40 | 41 | process { 42 | if (-not $AllExpired) { 43 | if ($DnsCacheReverse.Contains($CacheRecord.IPAddress)) { 44 | $DnsCacheReverse.Remove($CacheRecord.IPAddress) 45 | } 46 | if ($DnsCache.Contains($CacheRecord.Name)) { 47 | $DnsCache[$CacheRecord.Name] = $DnsCache[$CacheRecord.Name] | Where-Object { $_.IPAddress -ne $CacheRecord.IPAddress -and $_.RecordType -ne $CacheRecord.RecordType } 48 | if ($DnsCache[$CacheRecord.Name].Count -eq 0) { 49 | $DnsCache.Remove($CacheRecord.Name) 50 | } 51 | } 52 | } 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /Indented.DnsResolver/func/Update-InternalRootHints.ps1: -------------------------------------------------------------------------------- 1 | function Update-InternalRootHints { 2 | # .SYNOPSIS 3 | # Updates the root hints file from InterNIC then re-initializes the internal cache. 4 | # .DESCRIPTION 5 | # The root hints file is used as the basis of an internal DNS cache. The content of the root hints file is used during iterative name resolution. 6 | # .PARAMETER Source 7 | # Update-InternalRootHints attempts to download a named.root file from InterNIC by default. An alternative root hints source may be specified here. 8 | # .INPUTS 9 | # System.String 10 | # .EXAMPLE 11 | # Update-InternalRootHints 12 | # .NOTES 13 | # Author: Chris Dent 14 | # 15 | # Change log: 16 | # 13/01/2015 - Chris Dent - Forked from source module. 17 | 18 | [CmdLetBinding()] 19 | param( 20 | [URI]$Source = "http://www.internic.net/domain/named.root" 21 | ) 22 | 23 | Get-WebContent $Source -FileName $psscriptroot\..\var\named.root 24 | Initialize-InternalDnsCache 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Indented.DnsResolver/var/named.root: -------------------------------------------------------------------------------- 1 | ; This file holds the information on root name servers needed to 2 | ; initialize cache of Internet domain name servers 3 | ; (e.g. reference this file in the "cache . " 4 | ; configuration file of BIND domain name servers). 5 | ; 6 | ; This file is made available by InterNIC 7 | ; under anonymous FTP as 8 | ; file /domain/named.cache 9 | ; on server FTP.INTERNIC.NET 10 | ; -OR- RS.INTERNIC.NET 11 | ; 12 | ; last update: Mar 26, 2014 13 | ; related version of root zone: 2014032601 14 | ; 15 | ; formerly NS.INTERNIC.NET 16 | ; 17 | . 3600000 IN NS A.ROOT-SERVERS.NET. 18 | A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4 19 | A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30 20 | ; 21 | ; FORMERLY NS1.ISI.EDU 22 | ; 23 | . 3600000 NS B.ROOT-SERVERS.NET. 24 | B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201 25 | ; 26 | ; FORMERLY C.PSI.NET 27 | ; 28 | . 3600000 NS C.ROOT-SERVERS.NET. 29 | C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12 30 | C.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2::C 31 | ; 32 | ; FORMERLY TERP.UMD.EDU 33 | ; 34 | . 3600000 NS D.ROOT-SERVERS.NET. 35 | D.ROOT-SERVERS.NET. 3600000 A 199.7.91.13 36 | D.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2D::D 37 | ; 38 | ; FORMERLY NS.NASA.GOV 39 | ; 40 | . 3600000 NS E.ROOT-SERVERS.NET. 41 | E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10 42 | ; 43 | ; FORMERLY NS.ISC.ORG 44 | ; 45 | . 3600000 NS F.ROOT-SERVERS.NET. 46 | F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241 47 | F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2F::F 48 | ; 49 | ; FORMERLY NS.NIC.DDN.MIL 50 | ; 51 | . 3600000 NS G.ROOT-SERVERS.NET. 52 | G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4 53 | ; 54 | ; FORMERLY AOS.ARL.ARMY.MIL 55 | ; 56 | . 3600000 NS H.ROOT-SERVERS.NET. 57 | H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53 58 | H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::803F:235 59 | ; 60 | ; FORMERLY NIC.NORDU.NET 61 | ; 62 | . 3600000 NS I.ROOT-SERVERS.NET. 63 | I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17 64 | I.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FE::53 65 | ; 66 | ; OPERATED BY VERISIGN, INC. 67 | ; 68 | . 3600000 NS J.ROOT-SERVERS.NET. 69 | J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30 70 | J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:C27::2:30 71 | ; 72 | ; OPERATED BY RIPE NCC 73 | ; 74 | . 3600000 NS K.ROOT-SERVERS.NET. 75 | K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129 76 | K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FD::1 77 | ; 78 | ; OPERATED BY ICANN 79 | ; 80 | . 3600000 NS L.ROOT-SERVERS.NET. 81 | L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42 82 | L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:3::42 83 | ; 84 | ; OPERATED BY WIDE 85 | ; 86 | . 3600000 NS M.ROOT-SERVERS.NET. 87 | M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33 88 | M.ROOT-SERVERS.NET. 3600000 AAAA 2001:DC3::35 89 | ; End of File 90 | -------------------------------------------------------------------------------- /Indented.NetworkTools/Indented.NetworkTools.Format.ps1xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Indented.NetworkTools.Subnet 6 | 7 | Indented.NetworkTools.Subnet 8 | 9 | 10 | 11 | 12 | 13 | left 14 | 15 | 16 | 17 | left 18 | 19 | 20 | 21 | left 22 | 23 | 24 | 25 | left 26 | 27 | 28 | 29 | left 30 | 31 | 32 | 33 | 34 | 35 | 36 | NetworkAddress 37 | 38 | 39 | BroadcastAddress 40 | 41 | 42 | SubnetMask 43 | 44 | 45 | SubnetLength 46 | 47 | 48 | HostAddresses 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /Indented.NetworkTools/Indented.NetworkTools.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.NetworkTools/Indented.NetworkTools.psd1 -------------------------------------------------------------------------------- /Indented.NetworkTools/Indented.NetworkTools.psm1: -------------------------------------------------------------------------------- 1 | # 2 | # Module loader for Indented.NetworkTools 3 | # 4 | # Author: Chris Dent 5 | # 6 | # Change log: 7 | # 02/04/2015 - Chris Dent - Refactored. 8 | # 05/07/2012 - Chris Dent - Created. 9 | 10 | 11 | # Static enumerations 12 | [Array]$Enum = @() 13 | 14 | if ($Enum.Count -ge 1) { 15 | New-Variable NetworkToolsModuleBuilder -Value (New-DynamicModuleBuilder Indented.NetworkTools -UseGlobalVariable $false) -Scope Script 16 | $Enum | ForEach-Object { 17 | Import-Module "$psscriptroot\enum\$_.ps1" 18 | } 19 | } 20 | 21 | # Private functions 22 | [Array]$Private = 'ConvertToNetworkObject' 23 | 24 | if ($Private.Count -ge 1) { 25 | $Private | ForEach-Object { 26 | Import-Module "$psscriptroot\func-priv\$_.ps1" 27 | } 28 | } 29 | 30 | # Public functions 31 | [Array]$Public = 'Connect-Socket', 32 | 'ConvertFrom-HexIP', 33 | 'ConvertTo-BinaryIP', 34 | 'ConvertTo-DecimalIP', 35 | 'ConvertTo-DottedDecimalIP', 36 | 'ConvertTo-HexIP', 37 | 'ConvertTo-Mask', 38 | 'ConvertTo-MaskLength', 39 | 'ConvertTo-Subnet', 40 | 'Disconnect-Socket', 41 | 'Get-BroadcastAddress', 42 | 'Get-NetworkAddress', 43 | 'Get-NetworkRange', 44 | 'Get-NetworkSummary', 45 | 'Get-Subnets', 46 | 'Get-WebContent', 47 | 'Get-WhoIs', 48 | 'New-BinaryReader', 49 | 'New-Socket', 50 | 'Receive-Bytes', 51 | 'Remove-Socket', 52 | 'Send-Bytes', 53 | 'Test-SmtpServer', 54 | 'Test-SubnetMember', 55 | 'Test-TcpPort', 56 | 'Test-UdpPort' 57 | 58 | if ($Public.Count -ge 1) { 59 | $Public | ForEach-Object { 60 | Import-Module "$psscriptroot\func\$_.ps1" 61 | } 62 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func-priv/ConvertToNetworkObject.ps1: -------------------------------------------------------------------------------- 1 | function ConvertToNetworkObject { 2 | # .SYNOPSIS 3 | # Converts IP address formats to a set a known styles. 4 | # .DESCRIPTION 5 | # Internal use only. 6 | # 7 | # ConvertToNetworkObject ensures consistent values are recorded from parameters which must handle differing addressing formats. This CmdLet allows all other the other functions in this module to offload parameter handling. 8 | # 9 | # Note: the functionality of this CmdLet is deliberately limited. Part of the reason this module exists is to demostrate (in small pieces) IP maths, if all of it is loaded into this hidden function it defeats the point. 10 | # .PARAMETER IPAddress 11 | # Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 12 | # .PARAMETER SubnetMask 13 | # A subnet mask as an IP address. 14 | # .INPUTS 15 | # System.String 16 | # .OUTPUTS 17 | # Indented.Net.NetworkObject 18 | # .NOTES 19 | # Author: Chris Dent 20 | # 21 | # Change log: 22 | # 14/01/2014 - Chris Dent - Created. 23 | 24 | [CmdLetBinding(DefaultParameterSetName = 'CIDRNotation')] 25 | param( 26 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeLine = $true, ParameterSetName = 'CIDRNotation')] 27 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'IPAndMask')] 28 | [String]$IPAddress, 29 | 30 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'IPAndMask')] 31 | [String]$SubnetMask 32 | ) 33 | 34 | $NetworkObject = New-Object PsObject -Property ([Ordered]@{ 35 | IPAddress = $null; 36 | SubnetMask = $null; 37 | MaskLength = [Byte]0; 38 | State = "No error"; 39 | }) 40 | $NetworkObject.PsObject.TypeNames.Add("Indented.Net.NetworkObject") 41 | 42 | # A bit of cleaning 43 | $IPAddress = $IPAddress.Trim() 44 | $SubnetMask = $SubnetMask.Trim() 45 | 46 | # Handling for IP and Mask as a single string 47 | if ($IPAddress -match '^(\S+)\s(\S+)$') { 48 | # Send it back into this function sort out the values now. 49 | return ConvertToNetworkObject $matches[1] $matches[2] 50 | } 51 | 52 | # IPAddress handling 53 | 54 | $IPAddressTest = New-Object IPAddress 0 55 | if ([IPAddress]::TryParse($IPAddress, [Ref]$IPAddressTest)) { 56 | if ($IPAddressTest.AddressFamily -eq [Net.Sockets.AddressFamily]::InterNetwork) { 57 | $NetworkObject.IPAddress = $IPAddressTest 58 | } else { 59 | $NetworkObject.State = "Unexpected IPv6 address for IPAddress." 60 | } 61 | } elseif ($myinvocation.BoundParameters.ContainsKey("SubnetMask")) { 62 | $NetworkObject.State = "Invalid IP address format." 63 | } else { 64 | # Begin string parsing 65 | if ($IPAddress -match '^(?(?:[0-9]{1,2}|[0-1][0-9]{2}|2[0-4][0-9]|25[0-5])(?:\.(?:[0-9]{1,2}|[0-1][0-9]{2}|2[0-4][0-9]|25[0-5])){0,3})[\\/](?\d+)$') { 66 | # Fix up the IP address 67 | $IPAddressBuilder = [Array]($matches.IPAddress -split '\.' | ForEach-Object { [Byte]$_ }) 68 | while ($IPAddressBuilder.Count -lt 4) { 69 | $IPAddressBuilder += 0 70 | } 71 | 72 | if ([IPAddress]::TryParse(($IPAddressBuilder -join '.'), [Ref]$IPAddressTest)) { 73 | $NetworkObject.IPAddress = $IPAddressTest 74 | } else { 75 | $NetworkObject.State = "Matched regular expression, but still failed to convert. Unexpected error." 76 | } 77 | 78 | # Hold this for a moment or two. 79 | [Byte]$MaskLength = $matches.SubnetMask 80 | } else { 81 | $NetworkObject.State = "Invalid CIDR notation format." 82 | } 83 | } 84 | 85 | # SubnetMask handling 86 | 87 | # Validation cannot be (easily) done using a regular expression. Hard-coding this as a string comparison should be nice and fast. 88 | # These can be dynamically generated as follows: 89 | # 90 | # 1..32 | ForEach-Object { ConvertTo-Mask $_ } 91 | # 92 | # However, the values never change and an array of strings takes little memory and requires no computation. 93 | $ValidSubnetMaskValues = "0.0.0.0", "128.0.0.0", "192.0.0.0", "224.0.0.0", "240.0.0.0", "248.0.0.0", "252.0.0.0", "254.0.0.0", "255.0.0.0", 94 | "255.128.0.0", "255.192.0.0", "255.224.0.0", "255.240.0.0", "255.248.0.0", "255.252.0.0", "255.254.0.0", "255.255.0.0", 95 | "255.255.128.0", "255.255.192.0", "255.255.224.0", "255.255.240.0", "255.255.248.0", "255.255.252.0", "255.255.254.0", "255.255.255.0", 96 | "255.255.255.128", "255.255.255.192", "255.255.255.224", "255.255.255.240", "255.255.255.248", "255.255.255.252", "255.255.255.254", "255.255.255.255" 97 | 98 | if ($myinvocation.BoundParameters.ContainsKey("SubnetMask") -and $NetworkObject.State -eq "No Error") { 99 | if ([IPAddress]::TryParse($SubnetMask, [Ref]$IPAddressTest)) { 100 | if ($IPAddressTest.AddressFamily -eq [Net.Sockets.AddressFamily]::InterNetwork) { 101 | if ($IPAddressTest.ToString() -notin $ValidSubnetMaskValues) { 102 | $NetworkObject.State = "Invalid subnet mask value." 103 | } else { 104 | $NetworkObject.SubnetMask = $IPAddressTest 105 | } 106 | } else { 107 | $NetworkObject.State = "Unexpected IPv6 address for SubnetMask." 108 | } 109 | } else { 110 | $NetworkObject.State = "Invalid subnet mask format." 111 | } 112 | } elseif ($NetworkObject.State -eq "No error") { 113 | if ($MaskLength -eq $null) { 114 | # Default the length to 32 bits. 115 | $NetworkObject.MaskLength = 32 116 | } elseif ($MaskLength -ge 0 -and $MaskLength -le 32) { 117 | $NetworkObject.MaskLength = $MaskLength 118 | } else { 119 | $NetworkObject.State = "Mask length out of range (expecting 0 to 32)." 120 | } 121 | } 122 | 123 | return $NetworkObject 124 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Connect-Socket.ps1: -------------------------------------------------------------------------------- 1 | function Connect-Socket { 2 | # .SYNOPSIS 3 | # Connect a TCP socket to a remote IP address and port. 4 | # .DESCRIPTION 5 | # If a TCP socket is being used as a network client it must first connect to a server before Send-Bytes and Receive-Bytes can be used. 6 | # .PARAMETER RemoteIPAddress 7 | # The remote IP address to connect to. 8 | # .PARAMETER RemotePort 9 | # The remote port to connect to. 10 | # .PARAMETER Socket 11 | # A socket created using New-Socket. 12 | # .INPUTS 13 | # System.Net.IPAddress 14 | # System.Net.Sockets.Socket 15 | # System.UInt16 16 | # .EXAMPLE 17 | # C:\PS>$Socket = New-Socket 18 | # C:\PS>Connect-Socket $Socket -RemoteIPAddress 10.0.0.2 -RemotePort 25 19 | # .NOTES 20 | # Author: Chris Dent 21 | # 22 | # Change log: 23 | # 06/01/2014 - Chris Dent - Created. 24 | 25 | [CmdLetBinding()] 26 | param( 27 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true)] 28 | [Net.Sockets.Socket]$Socket, 29 | 30 | [Parameter(Mandatory = $true)] 31 | [Alias('IPAddress')] 32 | [IPAddress]$RemoteIPAddress, 33 | 34 | [Parameter(Mandatory = $true)] 35 | [Alias('Port')] 36 | [UInt16]$RemotePort 37 | ) 38 | 39 | process { 40 | if ($Socket.ProtocolType -ne [Net.Sockets.ProtocolType]::Tcp) { 41 | Write-Error "Connect-Socket: The protocol type must be TCP to use Connect-Socket." -Category InvalidOperation -ErrorAction Stop 42 | } 43 | 44 | $RemoteEndPoint = [Net.EndPoint](New-Object Net.IPEndPoint($RemoteIPAddress, $RemotePort)) 45 | 46 | if ($Socket.Connected) { 47 | Write-Warning "Connect-Socket: The socket is connected to $($Socket.RemoteEndPoint). No action taken." 48 | } else { 49 | $Socket.Connect($RemoteEndPoint) 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertFrom-HexIP.ps1: -------------------------------------------------------------------------------- 1 | function ConvertFrom-HexIP { 2 | # .SYNOPSIS 3 | # Converts a hexadecimal IP address into a dotted decimal string. 4 | # .DESCRIPTION 5 | # ConvertFrom-HexIP takes a hexadecimal string and returns a dotted decimal IP address. An intermediate call is made to ConvertTo-DottedDecimalIP. 6 | # .PARAMETER IPAddress 7 | # An IP Address to convert. 8 | # .INPUTS 9 | # System.String 10 | # .OUTPUTS 11 | # System.Net.IPAddress 12 | # .EXAMPLE 13 | # ConvertFrom-HexIP c0a80001 14 | # 15 | # Returns the IP address 192.168.0.1. 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 13/10/2011 - Chris Dent - Created. 21 | 22 | [CmdLetBinding()] 23 | param( 24 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 25 | [ValidatePattern('^[0-9a-f]{8}$')] 26 | [String]$IPAddress 27 | ) 28 | 29 | process { 30 | return ConvertTo-DottedDecimalIP ([Convert]::ToUInt32($IPAddress, 16)) 31 | } 32 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertTo-BinaryIP.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-BinaryIP { 2 | # .SYNOPSIS 3 | # Converts a Decimal IP address into a binary format. 4 | # .DESCRIPTION 5 | # ConvertTo-BinaryIP uses System.Convert to switch between decimal and binary format. The output from this function is dotted binary. 6 | # .PARAMETER IPAddress 7 | # An IP Address to convert. 8 | # .INPUTS 9 | # System.Net.IPAddress 10 | # .OUTPUTS 11 | # System.String 12 | # .EXAMPLE 13 | # ConvertTo-BinaryIP 1.2.3.4 14 | # 15 | # Convert an IP address to a binary format. 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 25/11/2010 - Chris Dent - Created. 21 | 22 | [CmdLetBinding()] 23 | param( 24 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 25 | [IPAddress]$IPAddress 26 | ) 27 | 28 | process { 29 | return ($IPAddress.GetAddressBytes() | ForEach-Object { [Convert]::ToString($_, 2).PadLeft(8, '0') }) -join '.' 30 | } 31 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertTo-DecimalIP.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-DecimalIP { 2 | # .SYNOPSIS 3 | # Converts a Decimal IP address into a 32-bit unsigned integer. 4 | # .DESCRIPTION 5 | # ConvertTo-DecimalIP takes a decimal IP, uses a shift operation on each octet and returns a single UInt32 value. 6 | # .PARAMETER IPAddress 7 | # An IP Address to convert. 8 | # .INPUTS 9 | # System.Net.IPAddress 10 | # .OUTPUTS 11 | # System.UInt32 12 | # .EXAMPLE 13 | # ConvertTo-DecimalIP 1.2.3.4 14 | # 15 | # Converts an IP address to an unsigned 32-bit integer value. 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 25/11/2010 - Chris Dent - Created. 21 | 22 | [CmdLetBinding()] 23 | param( 24 | [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] 25 | [IPAddress]$IPAddress 26 | ) 27 | 28 | process { 29 | $i = 3; $DecimalIP = 0; 30 | $IPAddress.GetAddressBytes() | ForEach-Object { $DecimalIP += [UInt32]$_ -shl (8 * $i); $i-- } 31 | 32 | return [UInt32]$DecimalIP 33 | } 34 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertTo-DottedDecimalIP.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-DottedDecimalIP { 2 | # .SYNOPSIS 3 | # Converts either an unsigned 32-bit integer or a dotted binary string to an IP Address. 4 | # .DESCRIPTION 5 | # ConvertTo-DottedDecimalIP uses a regular expression match on the input string to convert to an IP address. 6 | # .PARAMETER IPAddress 7 | # A string representation of an IP address from either UInt32 or dotted binary. 8 | # .INPUTS 9 | # System.String 10 | # .OUTPUTS 11 | # System.Net.IPAddress 12 | # .EXAMPLE 13 | # ConvertTo-DottedDecimalIP 11000000.10101000.00000000.00000001 14 | # 15 | # Convert the binary form back to dotted decimal, resulting in 192.168.0.1. 16 | # .EXAMPLE 17 | # ConvertTo-DottedDecimalIP 3232235521 18 | # 19 | # Convert the decimal form back to dotted decimal, resulting in 192.168.0.1. 20 | # .NOTES 21 | # Author: Chris Dent 22 | # 23 | # Change log: 24 | # 25/11/2010 - Chris Dent - Created. 25 | 26 | [CmdLetBinding()] 27 | param( 28 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 29 | [String]$IPAddress 30 | ) 31 | 32 | process { 33 | switch -regex ($IPAddress) { 34 | "([01]{8}\.){3}[01]{8}" { 35 | return [IPAddress]([String]::Join('.', $( $IPAddress -split '\.' | ForEach-Object { [Convert]::ToUInt32($_, 2) } ))) 36 | } 37 | "\d" { 38 | $IPAddress = [UInt32]$IPAddress 39 | $DottedIP = 3..0 | ForEach-Object { 40 | $Remainder = $IPAddress % [Math]::Pow(256, $_) 41 | ($IPAddress - $Remainder) / [Math]::Pow(256, $_) 42 | $IPAddress = $Remainder 43 | } 44 | 45 | return [IPAddress]($DottedIP -join '.') 46 | } 47 | default { 48 | Write-Error "ConvertTo-DottedDecimalIP: Cannot convert this format" 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertTo-HexIP.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-HexIP { 2 | # .SYNOPSIS 3 | # Convert a dotted decimal IP address into a hexadecimal string. 4 | # .DESCRIPTION 5 | # ConvertTo-HexIP takes a dotted decimal IP and returns a single hexadecimal string value. 6 | # .PARAMETER IPAddress 7 | # An IP Address to convert. 8 | # .INPUTS 9 | # System.Net.IPAddress 10 | # .OUTPUTS 11 | # System.String 12 | # .EXAMPLE 13 | # ConvertTo-HexIP 192.168.0.1 14 | # 15 | # Returns the hexadecimal string c0a80001. 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 13/10/2011 - Chris Dent - Refactored. 21 | 22 | [CmdLetBinding()] 23 | param( 24 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 25 | [IPAddress]$IPAddress 26 | ) 27 | 28 | process { 29 | return ($IPAddress.GetAddressBytes() | ForEach-Object { '{0:x2}' -f $_ }) -join '' 30 | } 31 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertTo-Mask.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-Mask { 2 | # .SYNOPSIS 3 | # Convert a mask length to a dotted-decimal subnet mask. 4 | # .DESCRIPTION 5 | # ConvertTo-Mask returns a subnet mask in dotted decimal format from an integer value ranging between 0 and 32. 6 | # 7 | # ConvertTo-Mask creates a binary string from the length, converts the string to an unsigned 32-bit integer then calls ConvertTo-DottedDecimalIP to complete the operation. 8 | # .PARAMETER MaskLength 9 | # The number of bits which must be masked. 10 | # .INPUTS 11 | # System.Int32 12 | # .OUTPUTS 13 | # System.Net.IPAddress 14 | # .EXAMPLE 15 | # ConvertTo-Mask 24 16 | # 17 | # Returns the dotted-decimal form of the mask, 255.255.255.0. 18 | # .NOTES 19 | # Author: Chris Dent 20 | # 21 | # Change log: 22 | # 25/11/2010 - Chris Dent - Created. 23 | 24 | [CmdLetBinding()] 25 | param( 26 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 27 | [Alias("Length")] 28 | [ValidateRange(0, 32)] 29 | [Byte]$MaskLength 30 | ) 31 | 32 | process { 33 | return ConvertTo-DottedDecimalIP ([Convert]::ToUInt32($(("1" * $MaskLength).PadRight(32, "0")), 2)) 34 | } 35 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertTo-MaskLength.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-MaskLength { 2 | # .SYNOPSIS 3 | # Convert a dotted-decimal subnet mask to a mask length. 4 | # .DESCRIPTION 5 | # A simple count of the number of 1's in a binary string. 6 | # .PARAMETER SubnetMask 7 | # A subnet mask to convert into length. 8 | # .INPUTS 9 | # System.Net.IPAddress 10 | # .OUTPUTS 11 | # System.Int32 12 | # .EXAMPLE 13 | # ConvertTo-MaskLength 255.255.255.0 14 | # 15 | # Returns 24, the length of the mask in bits. 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 25/11/2010 - Chris Dent - Created. 21 | 22 | [CmdLetBinding()] 23 | param( 24 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 25 | [Alias("Mask")] 26 | [IPAddress]$SubnetMask 27 | ) 28 | 29 | process { 30 | $Params = ConvertToNetworkObject 0 $SubnetMask 31 | if ($Params.State -ne "No error") { 32 | Write-Error $Params.State -Category InvalidArgument 33 | return 34 | } 35 | 36 | $Bits = (($SubnetMask.GetAddressBytes() | ForEach-Object { [Convert]::ToString($_, 2) }) -join '') -replace '0' 37 | 38 | return $Bits.Length 39 | } 40 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/ConvertTo-Subnet.ps1: -------------------------------------------------------------------------------- 1 | function ConvertTo-Subnet { 2 | # .SYNOPSIS 3 | # Convert a start and end IP address to the closest matching subnet. 4 | # .DESCRIPTION 5 | # ConvertTo-Subnet attempts to convert a starting and ending IP address from a range to the closest subnet. 6 | # .PARAMETER Start 7 | # The first IP address from a range. 8 | # .PARAMETER End 9 | # The last IP address from a range. 10 | # .INPUTS 11 | # System.Net.IPAddress 12 | # .OUTPUTS 13 | # Indented.NetworkTools.NetworkSummary 14 | # .EXAMPLE 15 | # ConvertTo-Subnet 0.0.0.0 255.255.255.255 16 | # .EXAMPLE 17 | # ConvertTo-Subnet 192.168.0.1 192.168.0.129 18 | # .EXAMPLE 19 | # ConvertTo-Subnet 10.0.0.1 11.0.0.1 20 | # .EXAMPLE 21 | # ConvertTo-Subnet 10.0.0.126 10.0.0.129 22 | # .EXAMPLE 23 | # ConvertTo-Subnet 10.0.0.128 10.0.0.128 24 | # .EXAMPLE 25 | # ConvertTo-Subnet 10.0.0.128 10.0.0.130 26 | # .NOTES 27 | # Author: Chris Dent 28 | # 29 | # Change log: 30 | # 14/05/2014 - Chris Dent - Created. 31 | 32 | [CmdLetBinding()] 33 | param( 34 | [IPAddress]$Start, 35 | 36 | [IPAddress]$End 37 | ) 38 | 39 | if ($Start -eq $End) { 40 | return (Get-NetworkSummary "$Start\32") 41 | } 42 | 43 | $DecimalStart = ConvertTo-DecimalIP $Start 44 | $DecimalEnd = ConvertTo-DecimalIP $End 45 | 46 | $i = 32 47 | do { 48 | $i-- 49 | } until (($DecimalStart -band ([UInt32]1 -shl $i)) -ne ($DecimalEnd -band ([UInt32]1 -shl $i))) 50 | return (Get-NetworkSummary "$Start\$(32 - $i - 1)") 51 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Disconnect-Socket.ps1: -------------------------------------------------------------------------------- 1 | function Disconnect-Socket { 2 | # .SYNOPSIS 3 | # Disconnect a connected TCP socket. 4 | # .DESCRIPTION 5 | # A TCP socket which has been connected using Connect-Socket may be disconnected using this CmdLet. 6 | # .PARAMETER Shutdown 7 | # By default, Disconnect-Socket attempts to shutdown the connection before disconnecting. This behaviour can be overridden by setting this parameter to False. 8 | # .PARAMETER Socket 9 | # A socket created using New-Socket and connected using Connect-Socket. 10 | # .INPUTS 11 | # System.Net.Sockets.Socket 12 | # .EXAMPLE 13 | # C:\PS>$Socket = New-Socket 14 | # C:\PS>$Socket | Connect-Socket -RemoteIPAddress 10.0.0.2 -RemotePort 25 15 | # C:\PS>$Socket | Disconnect-Socket 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 06/01/2014 - Chris Dent - Created. 21 | 22 | [CmdLetBinding()] 23 | param( 24 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true)] 25 | [Net.Sockets.Socket]$Socket, 26 | 27 | [Boolean]$Shutdown = $true 28 | ) 29 | 30 | process { 31 | if ($Socket.ProtocolType -ne [Net.Sockets.ProtocolType]::Tcp) { 32 | Write-Error "Disconnect-Socket: The protocol type must be TCP to use Disconnect-Socket." -Category InvalidOperation 33 | return 34 | } 35 | 36 | if (-not $Socket.Connected) { 37 | Write-Warning "Disconnect-Socket: The socket is not connected. No action taken." 38 | } else { 39 | Write-Verbose "Disconnect-Socket: Disconnected socket from $($Socket.RemoteEndPoint)." 40 | 41 | if ($Shutdown) { 42 | $Socket.Shutdown([Net.Sockets.SocketShutdown]::Both) 43 | } 44 | 45 | # Disconnect the socket and allow reuse. 46 | $Socket.Disconnect($true) 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Get-BroadcastAddress.ps1: -------------------------------------------------------------------------------- 1 | function Get-BroadcastAddress { 2 | # .SYNOPSIS 3 | # Get the broadcast address for a network range. 4 | # .DESCRIPTION 5 | # Get-BroadcastAddress returns the broadcast address for a subnet by performing a bitwise AND operation against the decimal forms of the IP address and inverted subnet mask. 6 | # .PARAMETER IPAddress 7 | # Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 8 | # .PARAMETER SubnetMask 9 | # A subnet mask as an IP address. 10 | # .INPUTS 11 | # System.String 12 | # .OUTPUTS 13 | # System.Net.IPAddress 14 | # .EXAMPLE 15 | # Get-BroadcastAddress 192.168.0.243 255.255.255.0 16 | # 17 | # Returns the address 192.168.0.255. 18 | # .EXAMPLE 19 | # Get-BroadcastAddress 10.0.9/22 20 | # 21 | # Returns the address 10.0.11.255. 22 | # .EXAMPLE 23 | # Get-BroadcastAddress 0/0 24 | # 25 | # Returns the address 255.255.255.255. 26 | # .EXAMPLE 27 | # Get-BroadcastAddress "10.0.0.42 255.255.255.252" 28 | # 29 | # Input values are automatically split into IP address and subnet mask. Returns the address 10.0.0.43. 30 | # .NOTES 31 | # Author: Chris Dent 32 | # 33 | # Change log: 34 | # 25/11/2010 - Chris Dent - Created. 35 | 36 | [CmdLetBinding(DefaultParameterSetName = 'CIDRNotation')] 37 | param( 38 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = 'CIDRNotation')] 39 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'IPAndMask')] 40 | [String]$IPAddress, 41 | 42 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'IPAndMask')] 43 | [String]$SubnetMask 44 | ) 45 | 46 | process { 47 | $Params = ConvertToNetworkObject "$IPAddress $SubnetMask" 48 | if ($Params.State -ne "No error") { 49 | Write-Error $Params.State -Category InvalidArgument 50 | return 51 | } elseif (-not $Params.SubnetMask) { 52 | $Params.SubnetMask = ConvertTo-Mask $Params.MaskLength 53 | } 54 | 55 | return ConvertTo-DottedDecimalIP $((ConvertTo-DecimalIP $Params.IPAddress) -bor ((-bnot (ConvertTo-DecimalIP $Params.SubnetMask)) -band [UInt32]::MaxValue)) 56 | } 57 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Get-NetworkAddress.ps1: -------------------------------------------------------------------------------- 1 | function Get-NetworkAddress { 2 | # .SYNOPSIS 3 | # Get the network address for a network range. 4 | # .DESCRIPTION 5 | # Get-NetworkAddress returns the network address for a subnet by performing a bitwise AND operation against the decimal forms of the IP address and subnet mask. 6 | # .PARAMETER IPAddress 7 | # Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 8 | # .PARAMETER SubnetMask 9 | # A subnet mask as an IP address. 10 | # .INPUTS 11 | # System.String 12 | # .OUTPUTS 13 | # System.Net.IPAddress 14 | # .EXAMPLE 15 | # Get-NetworkAddress 192.168.0.243 255.255.255.0 16 | # 17 | # Returns the address 192.168.0.0. 18 | # .EXAMPLE 19 | # Get-NetworkAddress 10.0.9/22 20 | # 21 | # Returns the address 10.0.8.0. 22 | # .EXAMPLE 23 | # Get-NetworkAddress "10.0.23.21 255.255.255.224" 24 | # 25 | # Input values are automatically split into IP address and subnet mask. Returns the address 10.0.23.0. 26 | # .NOTES 27 | # Author: Chris Dent 28 | # 29 | # Change log: 30 | # 25/11/2010 - Chris Dent - Created. 31 | 32 | [CmdLetBinding(DefaultParameterSetName = 'CIDRNotation')] 33 | param( 34 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = 'CIDRNotation')] 35 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'IPAndMask')] 36 | [String]$IPAddress, 37 | 38 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'IPAndMask')] 39 | [String]$SubnetMask 40 | ) 41 | 42 | process { 43 | $Params = ConvertToNetworkObject "$IPAddress $SubnetMask" 44 | if ($Params.State -ne "No error") { 45 | Write-Error $Params.State -Category InvalidArgument 46 | return 47 | } elseif (-not $Params.SubnetMask) { 48 | $Params.SubnetMask = ConvertTo-Mask $Params.MaskLength 49 | } 50 | 51 | return ConvertTo-DottedDecimalIP ((ConvertTo-DecimalIP $Params.IPAddress) -band (ConvertTo-DecimalIP $Params.SubnetMask)) 52 | } 53 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Get-NetworkRange.ps1: -------------------------------------------------------------------------------- 1 | function Get-NetworkRange { 2 | # .SYNOPSIS 3 | # Get a list of IP addresses within the specified network. 4 | # .DESCRIPTION 5 | # Get-NetworkRange finds the network and broadcast address as decimal values then starts a counter between the two, returning IPAddress for each. 6 | # .PARAMETER IPAddress 7 | # Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 8 | # .PARAMETER SubnetMask 9 | # A subnet mask as an IP address. 10 | # .INPUTS 11 | # System.Net.IPAddress 12 | # System.String 13 | # .OUTPUTS 14 | # System.Net.IPAddress 15 | # .EXAMPLE 16 | # Get-NetworkRange 192.168.0.0 255.255.255.0 17 | # 18 | # Returns all IP addresses in the range 192.168.0.0/24. 19 | # .EXAMPLE 20 | # Get-NetworkRange 10.0.8.0/22 21 | # 22 | # Returns all IP addresses in the range 192.168.0.0 255.255.252.0. 23 | # .NOTES 24 | # Author: Chris Dent 25 | # 26 | # Change log: 27 | # 13/10/2011 - Chris Dent - Created. 28 | 29 | [CmdLetBinding(DefaultParameterSetName = 'CIDRNotation')] 30 | param( 31 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = 'CIDRNotation')] 32 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'IPAndMask')] 33 | [String]$IPAddress, 34 | 35 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'IPAndMask')] 36 | [String]$SubnetMask 37 | ) 38 | 39 | process { 40 | $Params = ConvertToNetworkObject "$IPAddress $SubnetMask" 41 | if ($Params.State -ne "No error") { 42 | Write-Error $Params.State -Category InvalidArgument 43 | return 44 | } elseif (-not $Params.SubnetMask) { 45 | $Params.SubnetMask = ConvertTo-Mask $Params.MaskLength 46 | } 47 | 48 | $DecimalIP = ConvertTo-DecimalIP $Params.IPAddress 49 | $DecimalMask = ConvertTo-DecimalIP $Params.SubnetMask 50 | 51 | $DecimalNetwork = $DecimalIP -band $DecimalMask 52 | $DecimalBroadcast = $DecimalIP -bor ((-bnot $DecimalMask) -band [UInt32]::MaxValue) 53 | 54 | for ($i = $($DecimalNetwork + 1); $i -lt $DecimalBroadcast; $i++) { 55 | ConvertTo-DottedDecimalIP $i 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Get-NetworkSummary.ps1: -------------------------------------------------------------------------------- 1 | function Get-NetworkSummary { 2 | # .SYNOPSIS 3 | # Generates a summary describing several properties of a network range 4 | # .DESCRIPTION 5 | # Get-NetworkSummary uses many of the IP conversion CmdLets to provide a summary of a network range from any IP address in the range and a subnet mask. 6 | # .PARAMETER IPAddress 7 | # Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 8 | # .PARAMETER SubnetMask 9 | # A subnet mask as an IP address. 10 | # .INPUTS 11 | # System.Net.IPAddress 12 | # System.String 13 | # .OUTPUTS 14 | # System.Object 15 | # .EXAMPLE 16 | # Get-NetworkSummary 192.168.0.1 255.255.255.0 17 | # .EXAMPLE 18 | # Get-NetworkSummary 10.0.9.43/22 19 | # .EXAMPLE 20 | # Get-NetworkSummary 0/0 21 | # .NOTES 22 | # Author: Chris Dent 23 | # 24 | # Change log: 25 | # 25/11/2010 - Chris Dent - Created. 26 | 27 | [CmdLetBinding(DefaultParameterSetName = 'CIDRNotation')] 28 | param( 29 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = 'CIDRNotation')] 30 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'IPAndMask')] 31 | [String]$IPAddress, 32 | 33 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'IPAndMask')] 34 | [String]$SubnetMask 35 | ) 36 | 37 | process { 38 | $Params = ConvertToNetworkObject "$IPAddress $SubnetMask" 39 | if ($Params.State -ne "No error") { 40 | Write-Error $Params.State -Category InvalidArgument 41 | return 42 | } elseif (-not $Params.SubnetMask) { 43 | $Params.SubnetMask = ConvertTo-Mask $Params.MaskLength 44 | } 45 | 46 | $DecimalIP = ConvertTo-DecimalIP $Params.IPAddress 47 | $DecimalMask = ConvertTo-DecimalIP $Params.SubnetMask 48 | $DecimalNetwork = $DecimalIP -band $DecimalMask 49 | $DecimalBroadcast = $DecimalIP -bor ((-bnot $DecimalMask) -band [UInt32]::MaxValue) 50 | 51 | $NetworkSummary = New-Object PSObject -Property ([Ordered]@{ 52 | NetworkAddress = (ConvertTo-DottedDecimalIP $DecimalNetwork); 53 | NetworkDecimal = $DecimalNetwork 54 | BroadcastAddress = (ConvertTo-DottedDecimalIP $DecimalBroadcast); 55 | BroadcastDecimal = $DecimalBroadcast 56 | Mask = $Params.SubnetMask; 57 | MaskLength = (ConvertTo-MaskLength $Params.SubnetMask); 58 | MaskHexadecimal = (ConvertTo-HexIP $Params.SubnetMask); 59 | HostRange = ""; 60 | NumberOfAddresses = ($DecimalBroadcast - $DecimalNetwork + 1) 61 | NumberOfHosts = ($DecimalBroadcast - $DecimalNetwork - 1); 62 | Class = ""; 63 | IsPrivate = $false 64 | }) 65 | $NetworkSummary.PsObject.TypeNames.Add("Indented.NetworkTools.NetworkSummary") 66 | 67 | if ($NetworkSummary.NumberOfHosts -lt 0) { 68 | $NetworkSummary.NumberOfHosts = 0 69 | } 70 | if ($NetworkSummary.MaskLength -lt 31) { 71 | $NetworkSummary.HostRange = [String]::Format("{0} - {1}", 72 | (ConvertTo-DottedDecimalIP ($DecimalNetwork + 1)), 73 | (ConvertTo-DottedDecimalIP ($DecimalBroadcast - 1))) 74 | } 75 | 76 | switch -regex (ConvertTo-BinaryIP $Params.IPAddress) { 77 | "^1111" { $NetworkSummary.Class = "E"; break } 78 | "^1110" { $NetworkSummary.Class = "D"; break } 79 | "^11000000.10101000" { $NetworkSummary.Class = "C"; if ($NetworkSummary.MaskLength -ge 16) { $NetworkSummary.IsPrivate = $true }; break } 80 | "^110" { $NetworkSummary.Class = "C" } 81 | "^10101100.0001" { $NetworkSummary.Class = "B"; if ($NetworkSummary.MaskLength -ge 12) { $NetworkSummary.IsPrivate = $true }; break } 82 | "^10" { $NetworkSummary.Class = "B"; break } 83 | "^00001010" { $NetworkSummary.Class = "A"; if ($NetworkSummary.MaskLength -ge 8) { $NetworkSummary.IsPrivate = $true}; break } 84 | "^0" { $NetworkSummary.Class = "A"; break } 85 | } 86 | 87 | return $NetworkSummary 88 | } 89 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Get-Subnets.ps1: -------------------------------------------------------------------------------- 1 | function Get-Subnets { 2 | # .SYNOPSIS 3 | # Get a list of subnets of a given size within a defined supernet. 4 | # .DESCRIPTION 5 | # Generates a list of subnets for a given network range using either the address class or a user-specified value. 6 | # .PARAMETER NetworkAddress 7 | # Any address in the super-net range. Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 8 | # .PARAMETER SubnetMask 9 | # The desired mask, determines the size of the resulting subnets. Must be a valid subnet mask. 10 | # .PARAMETER SupernetLength 11 | # By default Get-Subnets uses the address class to determine the size of the supernet. Where the supernet describes the range of addresses being split. 12 | # .INPUTS 13 | # System.String 14 | # System.UInt32 15 | # .OUTPUTS 16 | # System.Object[] 17 | # .EXAMPLE 18 | # Get-Subnets 10.0.0.0 255.255.255.192 -SupernetLength 24 19 | # 20 | # Four /26 networks are returned. 21 | # .EXAMPLE 22 | # Get-Subnets 10.0.0.0 255.255.0.0 23 | # 24 | # The supernet size is assumed to be 8, the mask length for a class A network. 256 /16 networks are returned. 25 | # .EXAMPLE 26 | # Get-Subnets 0/8 -SupernetLength 0 27 | # .NOTES 28 | # Author: Chris Dent 29 | # 30 | # Change log: 31 | # 13/10/2011 - Chris Dent - Created. 32 | 33 | [CmdLetBinding(DefaultParameterSetName = 'CIDRNotation')] 34 | param( 35 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true, ParameterSetName = 'CIDRNotation')] 36 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'IPAndMask')] 37 | [String]$NetworkAddress, 38 | 39 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'IPAndMask')] 40 | [String]$SubnetMask, 41 | 42 | [ValidateRange(0, 32)] 43 | [UInt32]$SupernetLength 44 | ) 45 | 46 | process { 47 | $Params = ConvertToNetworkObject "$NetworkAddress $SubnetMask" 48 | if ($Params.State -ne "No error") { 49 | Write-Error $Params.State -Category InvalidArgument 50 | return 51 | } elseif (-not $Params.SubnetMask) { 52 | $Params.SubnetMask = ConvertTo-Mask $Params.MaskLength 53 | } elseif ($Params.MaskLength -eq 0) { 54 | $Params.MaskLength = ConvertTo-MaskLength $Params.SubnetMask 55 | } 56 | 57 | if (-not $myinvocation.BoundParameters.ContainsKey("SupernetLength")) { 58 | $SupernetLength = switch -regex (ConvertTo-BinaryIP $Params.IPAddress) { 59 | "^110" { 24 } 60 | "^10" { 16 } 61 | "^0" { 8 } 62 | default { 24 } 63 | } 64 | } 65 | 66 | if ($SupernetLength -gt $Params.MaskLength) { 67 | Write-Error "Subnet is larger than supernet. Aborting" 68 | return 69 | } 70 | 71 | $NumberOfNets = [Math]::Pow(2, ($Params.MaskLength - $SupernetLength)) 72 | $NumberOfAddresses = [Math]::Pow(2, (32 - $Params.MaskLength)) 73 | 74 | $DecimalAddress = ConvertTo-DecimalIP (Get-NetworkAddress "$($Params.IPAddress)/$SupernetLength") 75 | for ($i = 0; $i -lt $NumberOfNets; $i++) { 76 | $NetworkAddress = ConvertTo-DottedDecimalIP $DecimalAddress 77 | 78 | $Subnet = New-Object PsObject -Property ([Ordered]@{ 79 | NetworkAddress = $NetworkAddress; 80 | BroadcastAddress = (Get-BroadcastAddress $NetworkAddress $Params.SubnetMask); 81 | SubnetMask = $Params.SubnetMask; 82 | SubnetLength = $Params.MaskLength; 83 | HostAddresses = $( 84 | $NumberOfHosts = $NumberOfAddresses - 2 85 | if ($NumberOfHosts -lt 0) { 0 } else { $NumberOfHosts } 86 | ); 87 | }) 88 | $Subnet.PsObject.TypeNames.Add("Indented.NetworkTools.Subnet") 89 | 90 | $Subnet 91 | 92 | $DecimalAddress += $NumberOfAddresses 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Get-WebContent.ps1: -------------------------------------------------------------------------------- 1 | function Get-WebContent { 2 | # .SYNOPSIS 3 | # Get web content from a remote system. 4 | # .DESCRIPTION 5 | # Attempt to get content from a remote web server. 6 | # 7 | # Get-WebContent can ignore SSL errors or may be used to debug SSL connections. 8 | # .PARAMETER DebugSSL 9 | # Return the content found at the URL as well as the HTTP response and any certificates. 10 | # .PARAMETER FileName 11 | # Save the received content to the specified file. 12 | # .PARAMETER IgnoreSSLErrors 13 | # Ignore SSL errors when using an HTTPS connection. 14 | # .PARAMETER URL 15 | # The URL to receive content from. 16 | # .PARAMETER UseDefaultCredentials 17 | # Pass the credentials of the current user with the request. 18 | # .PARAMETER UseSystemProxy 19 | # Use IEs proxy settings and use default network credentials to authenticate against the proxy. 20 | # .INPUTS 21 | # System.URI 22 | # .OUTPUTS 23 | # Indented.Web.Response 24 | # System.String 25 | # .EXAMPLE 26 | # Get-WebContent "http://localhost" 27 | # 28 | # Get web content from the specified URL (raw HTML). 29 | # .EXAMPLE 30 | # Get-WebContent "https://someserver" -IgnoreSSLErrors 31 | # 32 | # Get the content from https://someserver, ignore any SSL errors that occur. 33 | # .EXAMPLE 34 | # Get-WebContent "https://www.google.co.uk" -DebugSSL | Select-Object -ExpandProperty SSLInformation 35 | # 36 | # Get the content from www.google.co.uk and display the SSL information. 37 | # .NOTES 38 | # Author: Chris Dent 39 | # 40 | # Change log: 41 | # 01/05/2015 - Chris Dent - Added proxy control. 42 | # 31/03/2015 - Chris Dent - Overhauled. 43 | # 08/05/2013 - Chris Dent - Created. 44 | 45 | [CmdLetBinding(DefaultParameterSetName = 'IgnoreSSLErrors')] 46 | param( 47 | [Parameter(Mandatory = $true, Position = 1)] 48 | [ValidateNotNullOrEmpty()] 49 | [URI]$URL, 50 | 51 | [String]$FileName, 52 | 53 | [Parameter(ParameterSetName='IgnoreSSLErrors')] 54 | [Switch]$IgnoreSSLErrors, 55 | 56 | [Parameter(ParameterSetName='DebugSSL')] 57 | [Switch]$DebugSSL, 58 | 59 | [Switch]$UseDefaultCredentials, 60 | 61 | [Switch]$UseSystemProxy 62 | ) 63 | 64 | $WebRequest = [Net.WebRequest]::Create($URL) 65 | $WebRequest.UseDefaultCredentials = $UseDefaultCredentials 66 | if ($DebugSSL) { 67 | # Immediately close the TCP connection. The intent is to debug SSL so SSL must be negotiated each time this is called. 68 | $WebRequest.KeepAlive = $false 69 | # Prevent caching of any content. 70 | $WebRequest.CachePolicy = New-Object Net.Cache.HttpRequestCachePolicy([Net.Cache.HttpRequestCacheLevel]::NoCacheNoStore) 71 | } 72 | if ($UseSystemProxy) { 73 | $WebRequest.Proxy = [Net.WebRequest]::GetSystemWebProxy() 74 | $WebRequest.Proxy.Credentials = [Net.CredentialCache]::DefaultNetworkCredentials 75 | } 76 | 77 | $ServerCertificateValidationCallback = [Net.ServicePointManager]::ServerCertificateValidationCallback 78 | 79 | if ($IgnoreSSLErrors) { 80 | [Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true } 81 | } elseif ($DebugSSL) { 82 | New-Variable SSLInformation -Scope Script -Force 83 | 84 | # Accept certificates regardless of errors, but make the certificate available as a variable. 85 | [Net.ServicePointManager]::ServerCertificateValidationCallback = { 86 | param( 87 | [Object]$Sender, 88 | [Security.Cryptography.X509Certificates.X509Certificate2]$Certificate, 89 | [Security.Cryptography.X509Certificates.X509Chain]$Chain, 90 | [Net.Security.SslPolicyErrors]$PolicyErrors 91 | ) 92 | 93 | # Using Select-Object here to instantiate new versions of each of these in memory. Some object type information will be lost. 94 | $Script:SSLInformation = New-Object PSObject -Property ([Ordered]@{ 95 | Certificate = $Certificate | Select-Object * 96 | Chain = $Chain | Select-Object * 97 | PolicyErrors = $PolicyErrors 98 | }) 99 | 100 | # Always accept the SSL connection regardless of the state of the certificate. 101 | return $true 102 | } 103 | } 104 | 105 | try { 106 | $HttpWebResponse = $WebRequest.GetResponse() 107 | } catch { 108 | $HttpWebResponse = $_.Exception.InnerException.Response 109 | } 110 | if ($HttpWebResponse.ContentType -like 'text/*') { 111 | $StreamReader = New-Object IO.StreamReader($HttpWebResponse.GetResponseStream(), [Text.Encoding]::UTF8) 112 | $WebContent = $StreamReader.ReadToEnd() 113 | } else { 114 | $Stream = $HttpWebResponse.GetResponseStream() 115 | $Buffer = New-Object Byte[] 100KB 116 | $WebContent = @() 117 | do { 118 | $Count = $Stream.Read($Buffer, 0, 100KB) 119 | $WebContent += $Buffer[0..$($Count - 1)] 120 | } until ($Count -le 0) 121 | } 122 | 123 | if ($psboundparameters.ContainsKey('FileName')) { 124 | if ($HttpWebResponse.ContentType -like 'text\*') { 125 | $WebContent | Set-Content $FileName 126 | } else { 127 | $WebContent | Set-Content $FileName -Encoding Byte 128 | } 129 | } 130 | 131 | if ($IgnoreSSLErrors -or -not $DebugSSL) { 132 | if (-not $psboundparameters.ContainsKey('FileName')) { 133 | $WebContent 134 | } 135 | } else { 136 | New-Object PSObject -Property ([Ordered]@{ 137 | WebContent = $WebContent 138 | HttpResponse = $HttpWebResponse 139 | SSLInformation = $Script:SSLInformation 140 | }) 141 | } 142 | 143 | [Net.ServicePointManager]::ServerCertificateValidationCallback = $ServerCertificateValidationCallback 144 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Get-WhoIs.ps1: -------------------------------------------------------------------------------- 1 | function Get-WhoIs { 2 | # .SYNOPSIS 3 | # Get a WhoIs record using servers published via whois-servers.net. 4 | # .DESCRIPTION 5 | # For IP lookups, Get-WhoIs uses whois.arin.net as a starting point, chasing referrals within the record to get to an authoritative answer. 6 | # 7 | # For name lookups, Get-WhoIs uses the whois-servers.net service to attempt to locate a whois server for the top level domain (TLD). 8 | # 9 | # Get-WhoIs connects directly to whois servers using TCP/43. 10 | # .PARAMETER Name 11 | # The name or IP address to locate the WhoIs record for. 12 | # .PARAMETER WhoIsServer 13 | # A WhoIs server to use for the query. Dynamically populated, but can be overridden. 14 | # .PARAMETER Command 15 | # A command to execute on the WhoIs server if the server requires a command prefixing before the query. 16 | # .INPUTS 17 | # System.String 18 | # .OUTPUTS 19 | # System.String 20 | # .EXAMPLE 21 | # Get-WhoIs indented.co.uk 22 | # .EXAMPLE 23 | # Get-WhoIs 10.0.0.1 24 | # .NOTES 25 | # Author: Chris Dent 26 | # 27 | # Change log: 28 | # 15/01/2014 - Chris Dent - Created. 29 | 30 | [CmdLetBinding()] 31 | param( 32 | [Parameter(Mandatory = $true)] 33 | [String]$Name, 34 | 35 | [String]$WhoIsServer, 36 | 37 | [String]$Command 38 | ) 39 | 40 | if (-not $WhoIsServer) { 41 | if ([IPAddress]::TryParse($Name, [Ref]$null) -or $Name.EndsWith("arpa")) { 42 | $WhoIsServer = $WhoIsServerName = "whois.arin.net" 43 | $Command = "n " 44 | } else { 45 | $WhoIsServer = $WhoIsServerName = "$($Name.Split('.')[-1]).whois-servers.net" 46 | } 47 | } 48 | if (-not ([Net.IPAddress]::TryParse($WhoIsServer, [Ref]$null))) { 49 | $WhoIsServerRecord = [Net.Dns]::GetHostEntry($WhoIsServer) | 50 | Select-Object -Expand AddressList | 51 | Select-Object -First 1 52 | $WhoIsServer = $WhoIsServerRecord.IPAddressToString 53 | } 54 | 55 | if ($WhoIsServer) { 56 | Write-Verbose "Get-WhoIs: Asking $WhoIsServerName ($WhoIsServer) for $Name using command $Command$Name" 57 | 58 | $Socket = New-Socket 59 | try { 60 | Connect-Socket $Socket -RemoteIPAddress $WhoIsServer -RemotePort 43 61 | } catch [Net.Sockets.SocketException] { 62 | $ErrorRecord = New-Object Management.Automation.ErrorRecord( 63 | (New-Object Net.Sockets.SocketException ($_.Exception.InnerException.NativeErrorCode)), 64 | "Connection to $IPAddress failed", 65 | [Management.Automation.ErrorCategory]::ConnectionError, 66 | $Socket) 67 | $pscmdlet.ThrowTerminatingError($ErrorRecord) 68 | } 69 | 70 | Send-Bytes $Socket -Data ("$Command$Name`r`n" | ConvertTo-Byte) 71 | 72 | $ReceivedData = @() 73 | do { 74 | $ReceivedData += Receive-Bytes $Socket -BufferSize 4096 75 | Write-Verbose "Get-WhoIs: Received $($ReceivedData[-1].BytesReceived) bytes from $($ReceivedData[-1].RemoteEndPoint.Address)" 76 | } until ($ReceivedData[-1].BytesReceived -eq 0) 77 | 78 | $WhoIsRecord = ConvertTo-String ($ReceivedData | Select-Object -ExpandProperty Data) 79 | if ($WhoIsRecord -match 'ReferralServer: whois://(.+):') { 80 | Write-Verbose "Get-WhoIs: Following referral for $Name to $($matches[1])" 81 | Get-WhoIs $Name -WhoIsServer $matches[1] 82 | } else { 83 | $WhoIsRecord 84 | } 85 | Disconnect-Socket $Socket 86 | Remove-Socket $Socket 87 | } 88 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/New-BinaryReader.ps1: -------------------------------------------------------------------------------- 1 | function New-BinaryReader { 2 | # .SYNOPSIS 3 | # Create a new extended instance of a System.IO.BinaryReader class from a Byte Array. 4 | # .DESCRIPTION 5 | # System.IO.BinaryReader reads all multi-byte values as little endian, to address this the following methods have been added to the object: 6 | # 7 | # * ReadBEUInt16 8 | # * ReadBEInt32 9 | # * ReadBEUInt32 10 | # * ReadBEUInt64 11 | # 12 | # In addition to handling big endian values, the following utility methods have been implemented: 13 | # 14 | # * PeakByte 15 | # * ReadIPv4Address 16 | # * ReadIPv6Address 17 | # * SetPositionMarker 18 | # 19 | # SetPositionMarker populates the PositionMarker property which is associated with the BytesFromMarker property. 20 | # .PARAMETER ByteArray 21 | # The byte array passed to this function is used to create a MemoryStream which is passed to the BinaryReader class. 22 | # .INPUTS 23 | # System.Byte[] 24 | # .OUTPUTS 25 | # System.IO.BinaryReader 26 | # 27 | # The class has been extended as described above. 28 | # .EXAMPLE 29 | # C:\PS>$ByteArray = [Byte[]](1, 2, 3, 4) 30 | # C:\PS>$Reader = New-BinaryReader $ByteArray 31 | # C:\PS>$Reader.PeakByte() 32 | # C:\PS>$Reader.ReadIPv4Address() 33 | # .NOTES 34 | # Author: Chris Dent 35 | # 36 | # Change log: 37 | # 16/08/2013 - Chris Dent - Created. 38 | 39 | [CmdLetBinding()] 40 | param( 41 | [Parameter(Mandatory = $true)] 42 | [Byte[]]$ByteArray 43 | ) 44 | 45 | $MemoryStream = New-Object IO.MemoryStream(,$ByteArray) 46 | $BinaryReader = New-Object IO.BinaryReader($MemoryStream) 47 | 48 | # Property: PositionMarker 49 | $BinaryReader | Add-Member PositionMarker -MemberType NoteProperty -Value 0 50 | # Property: BytesFromPositionMarker 51 | $BinaryReader | Add-Member BytesFromMarker -MemberType ScriptProperty -Value { 52 | $this.BaseStream.Position - $this.PositionMarker 53 | } 54 | 55 | # Method: SetPositionMarket - Set a position marker to allow simple progress tracking 56 | $BinaryReader | Add-Member SetPositionMarker -MemberType ScriptMethod -Value { 57 | $this.PositionMarker = $this.BaseStream.Position 58 | } 59 | # Method: PeekByte - Allows viewing the next byte, resetting the stream position afterwards 60 | $BinaryReader | Add-Member PeekByte -MemberType ScriptMethod -Value { 61 | if ($this.BaseStream.Capacity -ge ($this.BaseStream.Position + 1)) { 62 | [Byte]$Value = $this.PsBase.ReadByte() 63 | $this.BaseStream.Seek(-1, [IO.SeekOrigin]::Current) | Out-Null 64 | $Value 65 | } 66 | } 67 | # Method: ReadBEUInt16 - Read big endian UInt16 values 68 | $BinaryReader | Add-Member ReadBEUInt16 -MemberType ScriptMethod -Value { 69 | $Bytes = $this.ReadBytes(2) 70 | [Array]::Reverse($Bytes) 71 | [BitConverter]::ToUInt16($Bytes, 0) 72 | } 73 | # Method: ReadBEInt32 - Read big endian Int32 values 74 | $BinaryReader | Add-Member ReadBEInt32 -MemberType ScriptMethod -Value { 75 | $Bytes = $this.ReadBytes(4) 76 | [Array]::Reverse($Bytes) 77 | [BitConverter]::ToInt32($Bytes, 0) 78 | } 79 | # Method: ReadBEInt32 - Read big endian UInt32 values 80 | $BinaryReader | Add-Member ReadBEUInt32 -MemberType ScriptMethod -Value { 81 | $Bytes = $this.ReadBytes(4) 82 | [Array]::Reverse($Bytes) 83 | [BitConverter]::ToUInt32($Bytes, 0) 84 | } 85 | # Method: ReadBEInt48 - Read big endian UInt48 values (returns as UInt64) 86 | $BinaryReader | Add-Member ReadBEUInt48 -MemberType ScriptMethod -Value { 87 | $Bytes = $this.ReadBytes(6) 88 | $Length = $Bytes.Length 89 | [UInt64]$Value = 0 90 | for ($i = 0; $i -lt $Length; $i++) { 91 | $Value = $Value -bor ([UInt64]$Bytes[$i] -shl (8 * ($Length - $i - 1))) 92 | } 93 | $Value 94 | } 95 | # Method: ReadBEInt64 - Read big endian UInt64 values 96 | $BinaryReader | Add-Member ReadBEUInt64 -MemberType ScriptMethod -Value { 97 | $Bytes = $this.ReadBytes(8) 98 | [Array]::Reverse($Bytes) 99 | [BitConverter]::ToUInt64($Bytes, 0) 100 | } 101 | # Method: ReadIPv4Address - Read 4 bytes as an IPv4 address 102 | $BinaryReader | Add-Member ReadIPv4Address -MemberType ScriptMethod -Value { 103 | [IPAddress]([String]::Format("{0}.{1}.{2}.{3}", 104 | $this.ReadByte(), 105 | $this.ReadByte(), 106 | $this.ReadByte(), 107 | $this.ReadByte()) 108 | ) 109 | } 110 | # Method: ReadIPv6Address - Read 16 bytes as an IPv6 address 111 | $BinaryReader | Add-Member ReadIPv6Address -MemberType ScriptMethod -Value { 112 | [IPAddress]([String]::Format("{0:X}:{1:X}:{2:X}:{3:X}:{4:X}:{5:X}:{6:X}:{7:X}", 113 | $this.ReadBEUInt16(), 114 | $this.ReadBEUInt16(), 115 | $this.ReadBEUInt16(), 116 | $this.ReadBEUInt16(), 117 | $this.ReadBEUInt16(), 118 | $this.ReadBEUInt16(), 119 | $this.ReadBEUInt16(), 120 | $this.ReadBEUInt16()) 121 | ) 122 | } 123 | 124 | return $BinaryReader 125 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/New-Socket.ps1: -------------------------------------------------------------------------------- 1 | function New-Socket { 2 | # .SYNOPSIS 3 | # Creates a new network socket to use to send and receive packets over a network. 4 | # .DESCRIPTION 5 | # New-Socket creates an instance of System.Net.Sockets.Socket for use with Send-Bytes and Receive-Bytes. 6 | # .PARAMETER EnableBroadcast 7 | # Allows a UDP socket to send and receive datagrams from the directed or undirected broadcast IP address. 8 | # .PARAMETER LocalIPAddress 9 | # If configuring a server port (to listen for requests) an IP address may be defined. By default the Socket is created to listen on all available addresses. 10 | # .PARAMETER LocalPort 11 | # If configuring a server port (to listen for requests) the local port number must be defined. 12 | # .PARAMETER NoTimeout 13 | # By default, send and receive timeout values are set for all operations. These values can be overridden to allow configuration of a socket which will never stop either attempting to send or attempting to receive. 14 | # .PARAMETER ProtocolType 15 | # ProtocolType must be either TCP or UDP. This parameter also sets the SocketType to Stream for TCP and Datagram for UDP. 16 | # .PARAMETER ReceiveTimeout 17 | # A timeout for individual Receive operations performed with this socket. The default value is 5 seconds; this CmdLet allows the value to be set between 1 and 30 seconds. 18 | # .PARAMETER SendTimeout 19 | # A timeout for individual Send operations performed with this socket. The default value is 5 seconds; this CmdLet allows the value to be set between 1 and 30 seconds. 20 | # .INPUTS 21 | # System.Net.Sockets.ProtocolType 22 | # System.Net.IPAddress 23 | # System.UInt16 24 | # System.Int32 25 | # .OUTPUTS 26 | # System.Net.Sockets.Socket 27 | # .EXAMPLE 28 | # New-Socket -LocalPort 25 29 | # 30 | # Configure a socket to listen using TCP/25 (as a network server) on all locally configured IP addresses. 31 | # .EXAMPLE 32 | # New-Socket -ProtocolType Udp 33 | # 34 | # Configure a socket for sending UDP datagrams (as a network client). 35 | # .EXAMPLE 36 | # New-Socket -LocalPort 23 -LocalIPAddress 10.0.0.1 37 | # 38 | # Configure a socket to listen using TCP/23 (as a network server) on the IP address 10.0.0.1 (the IP address must exist and be bound to an interface). 39 | # .NOTES 40 | # Author: Chris Dent 41 | # 42 | # Change log: 43 | # 25/11/2010 - Chris Dent - Created. 44 | 45 | [CmdLetBinding(DefaultParameterSetName = 'ClientSocket')] 46 | param( 47 | [ValidateSet("Tcp", "Udp")] 48 | [Net.Sockets.ProtocolType]$ProtocolType = "Tcp", 49 | 50 | [Parameter(ParameterSetName = 'ServerSocket')] 51 | [IPAddress]$LocalIPAddress = [IPAddress]::Any, 52 | 53 | [Parameter(Mandatory = $true, ParameterSetName = 'ServerSocket')] 54 | [UInt16]$LocalPort, 55 | 56 | [Parameter(ParameterSetName = 'ClientSocket')] 57 | [Switch]$EnableBroadcast, 58 | 59 | [Switch]$IPv6, 60 | 61 | [Switch]$NoTimeout, 62 | 63 | [ValidateRange(1, 30)] 64 | [Int32]$ReceiveTimeOut = 5, 65 | 66 | [ValidateRange(1, 30)] 67 | [Int32]$SendTimeOut = 5 68 | ) 69 | 70 | switch ($ProtocolType) { 71 | ([Net.Sockets.ProtocolType]::Tcp) { $SocketType = [Net.Sockets.SocketType]::Stream; break } 72 | ([Net.Sockets.ProtocolType]::Udp) { $SocketType = [Net.Sockets.SocketType]::Dgram; break } 73 | } 74 | 75 | $AddressFamily = [Net.Sockets.AddressFamily]::InterNetwork 76 | 77 | if ($IPv6) { 78 | $AddressFamily = [Net.Sockets.AddressFamily]::Internetworkv6 79 | # If LocalIPAddress has not been explicitly defined, and IPv6 is expected, change to all IPv6 addresses. 80 | if ($LocalIPAddress -eq [IPAddress]::Any) { 81 | $LocalIPAddress = [IPAddress]::IPv6Any 82 | } 83 | } 84 | 85 | $Socket = New-Object Net.Sockets.Socket( 86 | $AddressFamily, 87 | $SocketType, 88 | $ProtocolType 89 | ) 90 | 91 | if ($EnableBroadcast) { 92 | if ($ProtocolType -eq [Net.Sockets.ProtocolType]::Udp) { 93 | $Socket.EnableBroadcast = $true 94 | } else { 95 | $ErrorRecord = New-Object Management.Automation.ErrorRecord( 96 | (New-Object ArgumentException "EnableBroadcast cannot be set for TCP sockets."), 97 | "ArgumentException", 98 | [Management.Automation.ErrorCategory]::InvalidArgument, 99 | $Socket) 100 | $pscmdlet.ThrowTerminatingError($ErrorRecord) 101 | } 102 | } 103 | 104 | # Bind a local end-point to listen for inbound requests. 105 | if ($pscmdlet.ParameterSetName -eq 'ServerSocket') { 106 | $LocalEndPoint = [Net.EndPoint](New-Object Net.IPEndPoint($LocalIPAddress, $LocalPort)) 107 | $Socket.Bind($LocalEndPoint) 108 | } 109 | 110 | # Set timeout values if applicable. 111 | if (-not $NoTimeout) { 112 | $Socket.SendTimeOut = $SendTimeOut * 1000 113 | $Socket.ReceiveTimeOut = $ReceiveTimeOut * 1000 114 | } 115 | 116 | return $Socket 117 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Receive-Bytes.ps1: -------------------------------------------------------------------------------- 1 | function Receive-Bytes { 2 | # .SYNOPSIS 3 | # Receive bytes using a TCP or UDP socket. 4 | # .DESCRIPTION 5 | # Receive-Bytes is used to accept inbound TCP or UDP packets as a client exepcting a response from a server, or as a server waiting for incoming connections. 6 | # 7 | # Receive-Bytes will listen for bytes sent to broadcast addresses provided the socket has been created using EnableBroadcast. 8 | # .PARAMETER BufferSize 9 | # The maximum buffer size used for each receive operation. 10 | # .PARAMETER Socket 11 | # A socket created using New-Socket. If the ProtocolType is TCP the socket must be connected first. 12 | # .INPUTS 13 | # System.Net.Sockets.Socket 14 | # System.UInt32 15 | # .EXAMPLE 16 | # C:\PS>$Socket = New-Socket 17 | # C:\PS>Connect-Socket $Socket -RemoteIPAddress 10.0.0.1 -RemotePort 25 18 | # C:\PS>$Bytes = Receive-Bytes $Socket 19 | # C:\PS>$Bytes | ConvertTo-String 20 | # .EXAMPLE 21 | # C:\PS>$Socket = New-Socket -ProtocolType Udp -EnableBroadcast 22 | # C:\PS>$Socket | Receive-Bytes 23 | # .NOTES 24 | # Author: Chris Dent 25 | # 26 | # Change log: 27 | # 25/11/2010 - Chris Dent - Created. 28 | 29 | [CmdLetBinding()] 30 | param( 31 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 32 | [Net.Sockets.Socket]$Socket, 33 | 34 | [UInt32]$BufferSize = 1024 35 | ) 36 | 37 | $Buffer = New-Object Byte[] $BufferSize 38 | 39 | switch ($Socket.ProtocolType) { 40 | ([Net.Sockets.ProtocolType]::Tcp) { 41 | $BytesReceived = $null; $BytesReceived = $Socket.Receive($Buffer) 42 | Write-Verbose "Receive-Bytes: Received $BytesReceived from $($Socket.RemoteEndPoint): Connection State: $($Socket.Connected)" 43 | 44 | $Response = New-Object PsObject -Property ([Ordered]@{ 45 | BytesReceived = $BytesReceived; 46 | Data = $Buffer[0..$($BytesReceived - 1)]; 47 | RemoteEndPoint = $Socket.RemoteEndPoint | Select-Object *; 48 | }) 49 | break 50 | } 51 | ([Net.Sockets.ProtocolType]::Udp) { 52 | # Create an IPEndPoint to use as a reference object 53 | if ($Socket.AddressFamily -eq [Net.Sockets.AddressFamily]::InterNetwork) { 54 | $RemoteEndPoint = [Net.EndPoint](New-Object Net.IPEndPoint([IPAddress]::Any, 0)) 55 | } elseif ($Socket.AddressFamily -eq [Net.Sockets.AddressFamily]::InterNetworkv6) { 56 | $RemoteEndPoint = [Net.EndPoint](New-Object Net.IPEndPoint([IPAddress]::IPv6Any, 0)) 57 | } 58 | 59 | $BytesReceived = $null; $BytesReceived = $Socket.ReceiveFrom($Buffer, [Ref]$RemoteEndPoint) 60 | Write-Verbose "Receive-Bytes: Received $BytesReceived from $($RemoteEndPoint.Address.IPAddressToString)" 61 | 62 | $Response = New-Object PsObject -Property ([Ordered]@{ 63 | BytesReceived = $BytesReceived; 64 | Data = $Buffer[0..$($BytesReceived - 1)]; 65 | RemoteEndPoint = $RemoteEndPoint | Select-Object *; 66 | }) 67 | break 68 | } 69 | } 70 | if ($Response) { 71 | $Response.PsObject.TypeNames.Add("Indented.Sockets.SocketResponse") 72 | return $Response 73 | } 74 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Remove-Socket.ps1: -------------------------------------------------------------------------------- 1 | function Remove-Socket { 2 | # .SYNOPSIS 3 | # Removes a socket, releasing all resources. 4 | # .DESCRIPTION 5 | # A socket may be removed using Remove-Socket if it is no longer required. 6 | # .PARAMETER Socket 7 | # A socket created using New-Socket. 8 | # .INPUTS 9 | # System.Net.Sockets.Socket 10 | # .EXAMPLE 11 | # C:\PS>$Socket = New-Socket 12 | # C:\PS>$Socket | Connect-Socket -RemoteIPAddress 10.0.0.2 -RemotePort 25 13 | # C:\PS>$Socket | Disconnect-Socket 14 | # C:\PS>$Socket | Remove-Socket 15 | # .NOTES 16 | # Author: Chris Dent 17 | # 18 | # Change log: 19 | # 25/11/2010 - Chris Dent - Created. 20 | 21 | [CmdLetBinding()] 22 | param( 23 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] 24 | [Net.Sockets.Socket]$Socket 25 | ) 26 | 27 | process { 28 | # Close the socket 29 | $Socket.Close() 30 | } 31 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Send-Bytes.ps1: -------------------------------------------------------------------------------- 1 | function Send-Bytes { 2 | # .SYNOPSIS 3 | # Sends bytes using a TCP or UDP socket. 4 | # .DESCRIPTION 5 | # Send-Bytes is used to send outbound TCP or UDP packets as a server responding to a cilent, or as a client sending to a server. 6 | # .PARAMETER Broadcast 7 | # Sets the RemoteIPAddress to the undirected broadcast address. 8 | # .PARAMETER RemoteIPAddress 9 | # If the Protocol Type is UDP a remote IP address must be defined. Directed or undirected broadcast addresses may be used if EnableBroadcast has been set on the socket. 10 | # .PARAMETER Socket 11 | # A socket created using New-Socket. If the ProtocolType is TCP the socket must be connected first. 12 | # .INPUTS 13 | # System.Net.Sockets.Socket 14 | # System.UInt32 15 | # .EXAMPLE 16 | # C:\PS>$Socket = New-Socket 17 | # C:\PS>Connect-Socket $Socket -RemoteIPAddress 10.0.0.1 -RemotePort 25 18 | # C:\PS>Send-Bytes $Socket -Data 0 19 | # .EXAMPLE 20 | # C:\PS>$Socket = New-Socket -ProtocolType Udp -EnableBroadcast 21 | # C:\PS>Send-Bytes $Socket -Data 0 22 | # .NOTES 23 | # Author: Chris Dent 24 | # 25 | # Change log: 26 | # 25/11/2010 - Chris Dent - Created. 27 | 28 | [CmdLetBinding(DefaultParameterSetName = 'DirectedTcpSend')] 29 | param( 30 | [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true)] 31 | [Net.Sockets.Socket]$Socket, 32 | 33 | [Parameter(Mandatory = $true, ParameterSetName = 'DirectedUdpSend')] 34 | [IPAddress]$RemoteIPAddress, 35 | 36 | [Parameter(Mandatory = $true, ParameterSetName = 'BroadcastUdpSend')] 37 | [Switch]$Broadcast, 38 | 39 | [Parameter(Mandatory = $true, ParameterSetname = 'DirectedUdpSend')] 40 | [Parameter(Mandatory = $true, ParameterSetName = 'BroadcastUdpSend')] 41 | [UInt16]$RemotePort, 42 | 43 | [Parameter(Mandatory = $true)] 44 | [Byte[]]$Data 45 | ) 46 | 47 | # Broadcast parameter set checking 48 | if ($pscmdlet.ParameterSetName -eq 'BroadcastUdpSend') { 49 | # IPv6 error checking 50 | if ($Socket.AddressFamily -eq [Net.Sockets.AddressFamily]::InterNetworkv6) { 51 | $ErrorRecord = New-Object Management.Automation.ErrorRecord( 52 | (New-Object ArgumentException "EnableBroadcast cannot be set for IPv6 sockets."), 53 | "ArgumentException", 54 | [Management.Automation.ErrorCategory]::InvalidArgument, 55 | $Socket) 56 | $pscmdlet.ThrowTerminatingError($ErrorRecord) 57 | } 58 | 59 | # TCP socket error checking 60 | if (-not $Socket.ProtocolType) { 61 | $ErrorRecord = New-Object Management.Automation.ErrorRecord( 62 | (New-Object ArgumentException "EnableBroadcast cannot be set for TCP sockets."), 63 | "ArgumentException", 64 | [Management.Automation.ErrorCategory]::InvalidArgument, 65 | $Socket) 66 | $pscmdlet.ThrowTerminatingError($ErrorRecord) 67 | } 68 | 69 | # Broadcast flag checking 70 | if (-not $Socket.EnableBroadcast) { 71 | $ErrorRecord = New-Object Management.Automation.ErrorRecord( 72 | (New-Object InvalidOperationException "EnableBroadcast is not set on the socket."), 73 | "InvalidOperation", 74 | [Management.Automation.ErrorCategory]::InvalidOperation, 75 | $Socket) 76 | $pscmdlet.ThrowTerminatingError($ErrorRecord) 77 | } 78 | 79 | $RemoteIPAddress = [IPAddress]::Broadcast 80 | } 81 | 82 | switch ($Socket.ProtocolType) { 83 | ([Net.Sockets.ProtocolType]::Tcp) { 84 | 85 | $Socket.Send($Data) | Out-Null 86 | 87 | break 88 | } 89 | ([Net.Sockets.ProtocolType]::Udp) { 90 | $RemoteEndPoint = [Net.EndPoint](New-Object Net.IPEndPoint($RemoteIPAddress, $RemotePort)) 91 | 92 | $Socket.SendTo($Data, $RemoteEndPoint) | Out-Null 93 | 94 | break 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Test-SmtpServer.ps1: -------------------------------------------------------------------------------- 1 | function Test-SmtpServer { 2 | # .SYNOPSIS 3 | # Test SMTP by executing a simple SMTP conversation. 4 | # .DESCRIPTION 5 | # Test-SmtpServer attemps to send an e-mail message using the specific SMTP server. 6 | # .PARAMETER From 7 | # A sender address. 8 | # .PARAMETER IPAddress 9 | # The server to connect to. 10 | # .PARAMETER Port 11 | # The TCP Port to use. By default, Port 25 is used. 12 | # .PARAMETER To 13 | # The recipient of the test e-mail. 14 | # .INPUTS 15 | # System.Net.IPAddress 16 | # System.String 17 | # System.UInt32 18 | # .OUTPUTS 19 | # System.Object 20 | # .EXAMPLE 21 | # Test-SmtpServer -IPAddress 1.2.3.4 -To "me@domain.example" -From "me@domain.example" 22 | # .NOTES 23 | # Author: Chris Dent 24 | # 25 | # Change log: 26 | # 15/04/2014 - Chris Dent - Created. 27 | 28 | [CmdLetBinding()] 29 | param( 30 | [Parameter(Mandatory = $true)] 31 | [IPAddress]$IPAddress, 32 | 33 | [UInt16]$Port = 25, 34 | 35 | [Parameter(Mandatory = $true)] 36 | [String]$To, 37 | 38 | [Parameter(Mandatory = $true)] 39 | [String]$From 40 | ) 41 | 42 | $CommandList = "helo there", "mail from: <$From>", "rcpt to: <$To>", "data", "Subject: Test message from Test-Smtp: $(Get-Date)`r`n." 43 | 44 | $Socket = New-Socket 45 | try { 46 | Connect-Socket $Socket -RemoteIPAddress $IPAddress -RemotePort $Port 47 | } catch [Net.Sockets.SocketException] { 48 | $ErrorRecord = New-Object Management.Automation.ErrorRecord( 49 | (New-Object Net.Sockets.SocketException ($_.Exception.InnerException.NativeErrorCode)), 50 | "Connection to $IPAddress failed", 51 | [Management.Automation.ErrorCategory]::ConnectionError, 52 | $Socket) 53 | $pscmdlet.ThrowTerminatingError($ErrorRecord) 54 | } 55 | 56 | New-Object PsObject -Property ([Ordered]@{ 57 | Operation = "RECEIVE"; 58 | Data = (Receive-Bytes $Socket | ConvertTo-String); 59 | }) 60 | 61 | # Send the remaining commands (terminated with CRLF, `r`n) and get the response 62 | $CommandList | ForEach-Object { 63 | New-Object PsObject -Property ([Ordered]@{ 64 | Operation = "SEND"; 65 | Data = $_; 66 | }) 67 | 68 | Send-Bytes $Socket -Data (ConvertTo-Byte "$_`r`n") 69 | 70 | New-Object PsObject -Property ([Ordered]@{ 71 | Operation = "RECEIVE"; 72 | Data = (Receive-Bytes $Socket | ConvertTo-String); 73 | }) 74 | } 75 | Disconnect-Socket $Socket 76 | Remove-Socket $Socket 77 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Test-SubnetMember.ps1: -------------------------------------------------------------------------------- 1 | function Test-SubnetMember { 2 | # .SYNOPSIS 3 | # Tests an IP address to determine if it falls within IP address range. 4 | # .DESCRIPTION 5 | # Test-SubnetMember attempts to determine whether or not an address or range falls within another range. The network and broadcast address are calculated the converted to decimal then compared to the decimal form of the submitted address. 6 | # .PARAMETER ObjectIPAddress 7 | # A representation of the object, the network to test against. Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 8 | # .PARAMETER ObjectSubnetMask 9 | # A subnet mask as an IP address. 10 | # .PARAMETER SubjectIPAddress 11 | # A representation of the subject, the network to be tested. Either a literal IP address, a network range expressed as CIDR notation, or an IP address and subnet mask in a string. 12 | # .PARAMETER SubjectSubnetMask 13 | # A subnet mask as an IP address. 14 | # .INPUTS 15 | # System.String 16 | # .OUTPUTS 17 | # System.Boolean 18 | # .EXAMPLE 19 | # Test-SubnetMember -SubjectIPAddress 10.0.0.0/24 -ObjectIPAddress 10.0.0.0/16 20 | # 21 | # Returns true as the subject network can be contained within the object network. 22 | # .EXAMPLE 23 | # Test-SubnetMember -SubjectIPAddress 192.168.0.0/16 -ObjectIPAddress 192.168.0.0/24 24 | # 25 | # Returns false as the subject network is larger the object network. 26 | # .EXAMPLE 27 | # Test-SubnetMember -SubjectIPAddress 10.2.3.4/32 -ObjectIPAddress 10.0.0.0/8 28 | # 29 | # Returns true as the subject IP address is within the object network. 30 | # .EXAMPLE 31 | # Test-SubnetMember -SubjectIPAddress 255.255.255.255 -ObjectIPAddress 0/0 32 | # 33 | # Returns true as the subject IP address is the last in the object network range. 34 | # .NOTES 35 | # Author: Chris Dent 36 | # 37 | # Change log: 38 | # 12/08/2013 - Chris Dent - Created. 39 | 40 | [CmdLetBinding(DefaultParameterSetName = 'CIDRNotation')] 41 | param( 42 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'CIDRNotation')] 43 | [Parameter(Mandatory = $true, Position = 1, ParameterSetName = 'IPAndMask')] 44 | [String]$SubjectIPAddress, 45 | 46 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'IPAndMask')] 47 | [String]$SubjectSubnetMask, 48 | 49 | [Parameter(Mandatory = $true, Position = 2, ParameterSetName = 'CIDRNotation')] 50 | [Parameter(Mandatory = $true, Position = 3, ParameterSetName = 'IPAndMask')] 51 | [String]$ObjectIPAddress, 52 | 53 | [Parameter(Mandatory = $true, Position = 4, ParameterSetName = 'IPAndMask')] 54 | [String]$ObjectSubnetMask 55 | ) 56 | 57 | $SubjectParams = ConvertToNetworkObject "$SubjectIPAddress $SubjectSubnetMask" 58 | if ($SubjectParams.State -ne "No error") { 59 | Write-Error "Subject: $($SubjectParams.State)" -Category InvalidArgument 60 | return 61 | } elseif (-not $SubjectParams.SubnetMask) { 62 | $SubjectParams.SubnetMask = ConvertTo-Mask $SubjectParams.MaskLength 63 | } 64 | 65 | $ObjectParams = ConvertToNetworkObject "$ObjectIPAddress $ObjectSubnetMask" 66 | if ($ObjectParams.State -ne "No error") { 67 | Write-Error "Object: $($ObjectParams.State)" -Category InvalidArgument 68 | return 69 | } elseif (-not $ObjectParams.SubnetMask) { 70 | $ObjectParams.SubnetMask = ConvertTo-Mask $ObjectParams.MaskLength 71 | } 72 | 73 | # A simple check, if the mask is shorter (larger network) then it won't be a subnet of the object anyway. 74 | if ($SubjectParams.MaskLength -lt $ObjectParams.MaskLength) { 75 | return $false 76 | } 77 | 78 | $SubjectDecimalIP = ConvertTo-DecimalIP $SubjectParams.IPAddress 79 | $ObjectDecimalNetwork = ConvertTo-DecimalIP (Get-NetworkAddress "$($ObjectParams.IPAddress) $($ObjectParams.SubnetMask)") 80 | $ObjectDecimalBroadcast = ConvertTo-DecimalIP (Get-BroadcastAddress "$($ObjectParams.IPAddress) $($ObjectParams.SubnetMask)") 81 | 82 | # If the mask is longer (smaller network), then the decimal form of the address must be between the 83 | # network and broadcast address of the object (the network we test against). 84 | if ($SubjectDecimalIP -ge $ObjectDecimalNetwork -and $SubjectDecimalIP -le $ObjectDecimalBroadcast) { 85 | return $true 86 | } else { 87 | return $false 88 | } 89 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Test-TcpPort.ps1: -------------------------------------------------------------------------------- 1 | function Test-TcpPort { 2 | # .SYNOPSIS 3 | # Test a TCP Port using System.Net.Sockets.TcpClient. 4 | # .DESCRIPTION 5 | # Test-TcpPort establishes a TCP connection to the sepecified port then immediately closes the connection, returning whether or not the connection succeeded. 6 | # 7 | # This function fully opens TCP connections (3-way handshake), it does not half-open connections. 8 | # .PARAMETER ComputerName 9 | # An host name or IP address for the target system. 10 | # .PARAMETER Port 11 | # The port number to connect to (between 1 and 655535). 12 | # .INPUTS 13 | # System.String 14 | # System.UInt16 15 | # .OUTPUTS 16 | # System.Boolean 17 | # .EXAMPLE 18 | # Test-TcpPort 10.0.0.1 3389 19 | # 20 | # Opens a TCP connection to 10.0.0.1 using port 3389. 21 | # .NOTES 22 | # Author: Chris Dent 23 | # 24 | # Change log: 25 | # 25/11/2010 - Chris Dent - Created. 26 | 27 | [CmdLetBinding()] 28 | param( 29 | [Parameter(Mandatory = $true)] 30 | [ValidateNotNullOrEmpty()] 31 | [String]$ComputerName, 32 | 33 | [Parameter(Mandatory = $true)] 34 | [ValidateNotNullOrEmpty()] 35 | [UInt16]$Port 36 | ) 37 | 38 | $TcpClient = New-Object Net.Sockets.TcpClient 39 | try { $TcpClient.Connect($ComputerName, $Port) } catch { } 40 | if ($?) { 41 | $TcpClient.Close() 42 | return $true 43 | } 44 | return $false 45 | } -------------------------------------------------------------------------------- /Indented.NetworkTools/func/Test-UdpPort.ps1: -------------------------------------------------------------------------------- 1 | function Test-UdpPort { 2 | # .SYNOPSIS 3 | # Attempt to whether a UDP port is willing to receive packets. 4 | # .DESCRIPTION 5 | # Test-UdpPort has a number of limitations due to the nature of UDP: 6 | # 7 | # * UDP is a connectionless protocol, reciept of the packet by the target cannot be guaranteed (or tested remotely). 8 | # * The remote server may elect to ignore the packet even if it has been received. 9 | # 10 | # Services such as DNS and NTP will not (or are not likely to) respond to a single byte packet. If they did the potential for amplification attacks would be quite extraordinary. 11 | # 12 | # Such limitations make this CmdLet moderately useless in a practical context without a sniffer or some other method of logging receipt of the generated packet on the target. 13 | # .PARAMETER ComputerName 14 | # An host name or IP address for the target system. 15 | # .PARAMETER Port 16 | # The port number to connect to (between 1 and 655535). 17 | # .INPUTS 18 | # System.String 19 | # System.UInt16 20 | # .OUTPUTS 21 | # System.Boolean 22 | # .EXAMPLE 23 | # Test-UdpPort 10.0.0.1 1001 24 | # 25 | # Send a single-byte packet to the UDP service running on port 1001 on the remote server. 26 | # .NOTES 27 | # Author: Chris Dent 28 | # 29 | # Change log: 30 | # 09/01/2015 - Chris Dent - Created. 31 | 32 | [CmdLetBinding()] 33 | param( 34 | [Parameter(Mandatory = $true)] 35 | [ValidateNotNullOrEmpty()] 36 | [String]$ComputerName, 37 | 38 | [Parameter(Mandatory = $true)] 39 | [ValidateNotNullOrEmpty()] 40 | [UInt16]$Port 41 | ) 42 | 43 | if (-not ([Net.IPAddress]::TryParse($ComputerName, [Ref]$null))) { 44 | $DnsRecord = [Net.Dns]::GetHostEntry($ComputerName) | 45 | Select-Object -Expand AddressList | 46 | Select-Object -First 1 47 | $ComputerName = $DnsRecord.IPAddressToString 48 | } 49 | 50 | # Set up a socket with a 5 second receive timeout. 51 | $UdpSocket = New-Socket -ProtocolType Udp -ReceiveTimeout 5 52 | Send-Bytes $UdpSocket -RemoteIPAddress $ComputerName -RemotePort $Port -Data 0 53 | # Listen for a reply on the socket. It is unlikely we'll see one. 54 | try { Receive-Bytes $UdpSocket } catch { } 55 | if ($?) { 56 | return $true 57 | } 58 | return $false 59 | } -------------------------------------------------------------------------------- /Indented.Utility/Indented.Utility.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/indented-automation/Indented/a9645667ff25b48a6875792a550b2291e04c89e8/Indented.Utility/Indented.Utility.psd1 -------------------------------------------------------------------------------- /Indented.Utility/Indented.Utility.psm1: -------------------------------------------------------------------------------- 1 | # 2 | # Module loader for Indented.Utility 3 | # 4 | # Author: Chris Dent 5 | # 6 | 7 | # Public functions 8 | [Array]$Public = 'Get-Manufacturer', 9 | 'Select-HIString', 10 | 'Update-ManufacturerList' 11 | 12 | if ($Public.Count -ge 1) { 13 | $Public | ForEach-Object { 14 | Import-Module "$psscriptroot\func\$_.ps1" 15 | } 16 | } -------------------------------------------------------------------------------- /Indented.Utility/func/Get-Manufacturer.ps1: -------------------------------------------------------------------------------- 1 | function Get-Manufacturer { 2 | # .SYNOPSIS 3 | # Get the manufacturer associated with a MAC address. 4 | # .DESCRIPTION 5 | # Get-Manufacturer attempts to find a manufacturer for a given MAC address. The list of manufacturers is cached locally in XML format, the function Update-ManufacturerList is used to populate and update the cached list. 6 | # .PARAMETER MACAddress 7 | # A partial or full MAC address, with or without delimiters. Accepted delimiters are ., - and :. 8 | # .INPUTS 9 | # System.String 10 | # .OUTPUTS 11 | # System.Object 12 | # .EXAMPLE 13 | # Get-Manufacturer 00:00:00:00:00:01 14 | # .EXAMPLE 15 | # Get-Manufacturer 000000000001 16 | # .EXAMPLE 17 | # Get-Manufacturer 00-00-00 18 | # .NOTES 19 | # Author: Chris Dent 20 | # 21 | # Change log: 22 | # 02/04/2015 - Chris Dent - Updated to use Indented.Common XPath CmdLets. 23 | # 08/05/2013 - Chris Dent - Created. 24 | 25 | [CmdLetBinding()] 26 | param( 27 | [Parameter(Mandatory = $true, ValueFromPipeLine = $true, ValueFromPipelineByPropertyname = $true)] 28 | [ValidatePattern('^([0-9A-Z]{2}[.\-:]?){2,5}([0-9A-Z]{2})')] 29 | [String]$MACAddress 30 | ) 31 | 32 | process { 33 | $MACAddress -match '([0-9A-Z]{2})[.\-:]?([0-9A-Z]{2})[.\-:]?([0-9A-Z]{2})' | Out-Null 34 | $OUI = [String]::Format("{0}-{1}-{2}", $matches[1], $matches[2], $matches[3]).ToUpper() 35 | 36 | $FilePath = "$psscriptroot\..\var\oui.xml" 37 | 38 | if (Test-Path $FilePath) { 39 | $XPathNavigator = New-XPathNavigator $FilePath 40 | 41 | $XPathNavigator.Select("/Manufacturers/Manufacturer[OUI='$OUI']") | 42 | ForEach-Object { 43 | $_ | ConvertFrom-XPathNode -ToObject 44 | } 45 | } else { 46 | Write-Warning "Get-Manufacturer: The manufacturer list does not exist. Run Update-ManufacturerList to create." 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Indented.Utility/func/Select-HIString.ps1: -------------------------------------------------------------------------------- 1 | function Select-HIString { 2 | # .SYNOPSIS 3 | # Select a matching string from an alphabetically sorted file. 4 | # .DESCRIPTION 5 | # Select-HIString is a specialised binary (Half Interval) searcher designed to find matches in sorted ASCII encoded text files. 6 | # .PARAMETER FileName 7 | # The name of the file to search. 8 | # .PARAMETER String 9 | # The string to find. The string is treated as a regular expression and must match the beginning of the line. 10 | # .INPUTS 11 | # System.String 12 | # .OUTPUTS 13 | # System.String 14 | # .EXAMPLE 15 | # Select-HIString -String abc -FileName File.txt 16 | # .NOTES 17 | # Author: Chris Dent 18 | # 19 | # Change log: 20 | # 11/08/2014 - Chris Dent - First release. 21 | 22 | param( 23 | [Parameter(Mandatory = $true)] 24 | [String]$String, 25 | 26 | [Parameter(Mandatory = $true)] 27 | [ValidateScript( { Test-Path $_ } )] 28 | [String]$FileName 29 | ) 30 | 31 | $FileName = (Get-Item $FileName).FullName 32 | $FileStream = New-Object IO.FileStream($FileName, [IO.FileMode]::Open) 33 | $BinaryReader = New-Object IO.BinaryReader($FileStream) 34 | 35 | $Length = $BinaryReader.BaseStream.Length 36 | $Position = $Length / 2 37 | 38 | [Int64]$HalfInterval = $Length / 2 39 | $Position = $Length - $HalfInterval 40 | 41 | while ($Position -gt 1 -and $Position -lt $Length -and $Position -ne $LastPosition) { 42 | $LastPosition = $Position 43 | $HalfInterval = $HalfInterval / 2 44 | 45 | $BinaryReader.BaseStream.Seek($Position, [IO.SeekOrigin]::Begin) | Out-Null 46 | 47 | # Track back to the start of the line 48 | while ($true) { 49 | $Character = $BinaryReader.ReadByte() 50 | if ($BinaryReader.BaseStream.Position -eq 1) { 51 | $BinaryReader.BaseStream.Seek(-1, [IO.SeekOrigin]::Current) | Out-Null 52 | break 53 | } elseif ($Character -eq [Byte][Char]"`n") { 54 | break 55 | } else { 56 | $BinaryReader.BaseStream.Seek(-2, [IO.SeekOrigin]::Current) | Out-Null 57 | } 58 | } 59 | 60 | # Read the line 61 | $Characters = @() 62 | if ($BinaryReader.BaseStream.Position -lt $BinaryReader.BaseStream.Length) { 63 | do { 64 | $Characters += [Char][Int]$BinaryReader.ReadByte() 65 | } until ($Characters[-1] -eq [Char]"`n" -or $BinaryReader.BaseStream.Position -eq $BinaryReader.BaseStream.Length) 66 | $Line = (New-Object String (,[Char[]]$Characters)).Trim() 67 | } else { 68 | # End of file 69 | $FileStream.Close() 70 | return $null 71 | } 72 | 73 | if ($Line -match "^$String") { 74 | # Close the file stream and return the match immediately 75 | $FileStream.Close() 76 | return $Line 77 | } elseif ($Line -lt $String) { 78 | $Position = $Position + $HalfInterval 79 | } elseif ($Line -gt $String) { 80 | $Position = $Position - $HalfInterval 81 | } 82 | } 83 | 84 | # Close the file stream if no matches are found. 85 | $FileStream.Close() 86 | } -------------------------------------------------------------------------------- /Indented.Utility/func/Update-ManufacturerList.ps1: -------------------------------------------------------------------------------- 1 | function Update-ManufacturerList { 2 | # .SYNOPSIS 3 | # Updates the cached manufacturer list maintained by the IEEE. 4 | # .DESCRIPTION 5 | # Update-ManufacturerList attempts to download the assigned list of MAC address prefixes using Get-WebContent. 6 | # 7 | # The return is converted into an XML format to act as the cache file for Get-Manufacturer. 8 | # .PARAMETER Source 9 | # By default, the manufacturer list is downloaded from http://standards.ieee.org/develop/regauth/oui/oui.txt. An alternate source may be specified if required. 10 | # .INPUTS 11 | # System.String 12 | # .EXAMPLE 13 | # Update-ManufacturerList 14 | # .NOTES 15 | # Author: Chris Dent 16 | # 17 | # Change log: 18 | # 02/04/2015 - Chris Dent - Refactored. 19 | # 08/05/2013 - Chris Dent - Created. 20 | 21 | [CmdLetBinding()] 22 | param( 23 | [String]$Source = "http://standards-oui.ieee.org/oui.txt" 24 | ) 25 | 26 | $Writer = New-Object IO.StreamWriter("$psscriptroot\..\var\oui.xml") 27 | $Writer.WriteLine("") 28 | $Writer.WriteLine("") 29 | 30 | Get-WebContent $Source -UseSystemProxy | 31 | ForEach-Object { 32 | switch -regex ($_) { 33 | '^\s*([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})\s+\(hex\)[\s\t]*(.+)$' { 34 | $OUI = $matches[1] 35 | $Organisation = $matches[2] 36 | break 37 | } 38 | '^\s*([0-9A-F]{6})\s+\(base 16\)[\s\t]*(.+)$' { 39 | $CompanyID = $matches[1] 40 | [Array]$Address = $matches[2] 41 | break 42 | } 43 | '^\s+(\S+.+)$' { 44 | $Address += $matches[1] 45 | break 46 | } 47 | '^\s*$' { 48 | if ($OUI -and $Organisation) { 49 | $Writer.WriteLine("") 50 | $Writer.WriteLine("$OUI") 51 | $Writer.WriteLine("") 52 | $Writer.WriteLine("$CompanyID") 53 | $Writer.WriteLine("
") 54 | $Writer.WriteLine("
") 55 | } 56 | $OUI = $null; $Organisation = $null; $CompanyID = $null; $Address = $null 57 | } 58 | } 59 | } 60 | 61 | $Writer.WriteLine("
") 62 | $Writer.Close() 63 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, TeflonJim <> 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Indented 2 | 3 | A collection of somewhat hierarchical modules including: 4 | 5 | * Indented.Common - A shared library 6 | * Indented.DnsResolver - A dig-like debug capable DNS resolver. 7 | * Indented.NetworkTools - IP maths and socket handling CmdLets. 8 | * Indented.Utility - A small collection of tools which don't fit anywhere else. 9 | 10 | Indented.Common 11 | --------------- 12 | 13 | * Compare-Array 14 | * ConvertFrom-XPathNode 15 | * ConvertTo-Byte 16 | * ConvertTo-String 17 | * ConvertTo-TimeSpanString 18 | * ConvertTo-Type 19 | * ConvertTo-Xml 20 | * Get-CommandParameters 21 | * Get-Hash 22 | * New-DynamicModuleBuilder 23 | * New-DynamicParameter 24 | * New-Enum 25 | * New-XPathNavigator 26 | * Set-XPathAttribute 27 | * Update-PropertyOrder 28 | 29 | Indented.DnsResolver 30 | -------------------- 31 | 32 | Requires: Indented.NetworkTools 33 | 34 | * Add-InternalDnsCacheRecord 35 | * Get-Dns 36 | * Get-DnsServerList 37 | * Get-InternalDnsCacheRecord 38 | * Initialize-InternalDnsCache 39 | * Remove-InternalDnsCacheRecord 40 | * Update-InternalRootHints 41 | 42 | Indented.NetworkTools 43 | --------------------- 44 | 45 | Requires: Indented.Common 46 | 47 | * Connect-Socket 48 | * ConvertFrom-HexIP 49 | * ConvertTo-BinaryIP 50 | * ConvertTo-DecimalIP 51 | * ConvertTo-DottedDecimalIP 52 | * ConvertTo-HexIP 53 | * ConvertTo-Mask 54 | * ConvertTo-MaskLength 55 | * ConvertTo-Subnet 56 | * Disconnect-Socket 57 | * Get-BroadcastAddress 58 | * Get-NetworkAddress 59 | * Get-NetworkRange 60 | * Get-NetworkSummary 61 | * Get-Subnets 62 | * Get-WebContent 63 | * Get-WhoIs 64 | * New-BinaryReader 65 | * New-Socket 66 | * Receive-Bytes 67 | * Remove-Socket 68 | * Send-Bytes 69 | * Test-SmtpServer 70 | * Test-SubnetMember 71 | * Test-TcpPort 72 | * Test-UdpPort 73 | 74 | Indented.Utilty 75 | --------------- 76 | 77 | Requires: Indented.NetworkTools 78 | 79 | * Get-Manufacturer 80 | * Select-HIString 81 | * Update-ManufacturerList --------------------------------------------------------------------------------