This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This gist just explains values of IFormatProvider argument of the ToString() method of the .NET type System.Guid | |
| # See more: https://learn.microsoft.com/ru-ru/dotnet/api/system.guid.tostring | |
| enum PSGuidFormatProvider { | |
| None = 0 # Only alphanumeric characters: 00000000000000000000000000000000 | |
| Braces = 1 # Figure brackets, "{}": {00000000-0000-0000-0000-000000000000} | |
| Dashes = 2 # Hyphens, "-": 00000000-0000-0000-0000-000000000000 | |
| Parentheses = 3 # Round brackets, "()": (00000000-0000-0000-0000-000000000000) | |
| Xadecimal = 4 # Groups of heXadecimal values: {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -Version 5.1 | |
| #Requires -Assembly "System.UriBuilder, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" | |
| #Requires -Assembly "System.Web.HttpUtility, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" | |
| <# | |
| .SYNOPSIS | |
| The function appends the username and password, both URL-encoded, to the specified URI. | |
| .DESCRIPTION | |
| The function appends the username and password, both URL-encoded, to the specified URI. | |
| It can be useful for cases where you need to specify a username and password in an HTTP request, and either the username or the password or both contain special characters that need to be escaped. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -Version 5.1 | |
| <# | |
| This PowerShell module contains a set of classes for comparing .NET objects that do not implement the IComparable interface, such as [System.Net.IPAddress], [System.Net.NetworkInformation.PhysicalAddress], [System.Security.Cryptography.Oid], [System.Uri]. | |
| #> | |
| enum PhysicalAddressCase { | |
| Default = 0 | |
| UpperCase = 1 | |
| LowerCase = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| A small and simple PowerShell function to convert enum types to a dictionary with enum numeric values as dictionary keys mapped to corresponding enum string names. | |
| .DESCRIPTION | |
| A small and simple PowerShell function to convert enum types to a dictionary with enum numeric values as dictionary keys mapped to corresponding enum string names. | |
| .PARAMETER Type | |
| Specifies the type as a [System.Type] object, or as a string containing the typename. Note that the function may throw an exception, if it fails to resolve a type by its short type name. | |
| .EXAMPLE | |
| PS C:\> Get-EnumValuesTable -Type "System.Security.AccessControl.AccessControlType" | |
| The function returns a sorted dictionary: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -Version 5.1 | |
| [System.FlagsAttribute()] | |
| enum PSCmdletCommonParameterSet { | |
| Common = 1 # 01 | |
| Optional = 2 # 10 | |
| } | |
| <# | |
| .SYNOPSIS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| The function takes a list of strings and pads each string with the Unicode space (0x0020) or any other specified character up to the length of the longest string in the list. | |
| .DESCRIPTION | |
| The function takes a list of strings and pads each string with the Unicode space (0x0020) or any other specified character up to the length of the longest string in the list. | |
| The function may be useful for formatting the console output of various objects. | |
| .PARAMETER InputList | |
| Specifies a list of input strings | |
| .PARAMETER Padding | |
| Specifies a padding direction. The acceptable values are "PadLeft" and "PadRight", which are .NET method names of type [System.String]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-ADObjGroupMembership { | |
| [CmdletBinding()] | |
| [OutputType([Microsoft.ActiveDirectory.Management.ADObject])] | |
| param ( | |
| # Parameter help description | |
| [Parameter( | |
| Mandatory = $true, | |
| ValueFromPipeline = $true, | |
| Position = 0 | |
| )] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| The function receives a GUID as an object or byte array and returns an escaped string for use in LDAP queries. | |
| .DESCRIPTION | |
| The function receives a GUID as an object or byte array and returns an escaped string for use in LDAP queries. In both cases, the function accepts pipeline input. | |
| .EXAMPLE | |
| PS C:\> Get-GuidEscapedForLDAP -Guid "bf967961-0de6-11d0-a285-00aa003049e2" | |
| The function returns the string: "\61\79\96\bf\e6\d\d0\11\a2\85\0\aa\0\30\49\e2". | |
| .EXAMPLE | |
| PS C:\> Get-GuidEscapedForLDAP -Byte (([guid]'bf967961-0de6-11d0-a285-00aa003049e2').ToByteArray()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -Version 5.1 | |
| # This enum can be interpreted as [System.Boolean], where "False" means that the current user session is in a disconnected state | |
| enum QuserSessionState { | |
| Idle = 0 | |
| Active = 1 | |
| } | |
| class QuserSession { | |
| # Property: stores the computer name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| The function returns a date and time value that is older than the current date and time by the specified number of hours, minutes, seconds, years etc. | |
| .DESCRIPTION | |
| The function returns a date and time value that is older than the current date and time by the specified number of hours, minutes, seconds, years etc. | |
| This function may be useful for working with items older than a specified date, e.g., for log rotation. | |
| .PARAMETER Years | |
| Specifies max item age in years. | |
| .PARAMETER Months | |
| Specifies max item age in months. |