Skip to content

Instantly share code, notes, and snippets.

View indented-automation's full-sized avatar

Chris Dent indented-automation

View GitHub Profile
@indented-automation
indented-automation / Get-DhcpClientOption.ps1
Created July 12, 2022 15:43
A partial parser for DHCP options in Windows
function Get-DhcpClientOption {
[CmdletBinding()]
param ( )
$adapters = Get-CimInstance Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=TRUE AND DhcpEnabled=TRUE'
foreach ($adapter in $adapters) {
$params = @{
LiteralPath = Join-Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces' -ChildPath $adapter.SettingID
Name = 'DhcpInterfaceOptions'
}
function Update-ManufacturerList {
<#
.SYNOPSIS
Updates the cached manufacturer list maintained by the IEEE.
.DESCRIPTION
Update-ManufacturerList attempts to download the assigned list of MAC address prefixes using Get-WebContent.
The return is converted into an XML format to act as the cache file for Get-Manufacturer.
.PARAMETER Source
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.
@indented-automation
indented-automation / Enable-ScriptAlias.ps1
Last active February 29, 2024 07:50
A bit of fun, replaces full command names with aliases
using namespace System.Management.Automation.Language
function Enable-ScriptAlias {
<#
.SYNOPSIS
Replace all aliased commands in a script with the alias name.
.DESCRIPTION
Replace all aliased commands in a script with the alias name.
$request = @{
Uri = 'https://api.pushover.net/1/messages.json'
Method = 'POST'
ContentType = 'application/x-www-form-urlencoded'
Body = @{
token = 'abc123'
user = 'user123'
message = 'hello world'
}
}
@indented-automation
indented-automation / ConvertFrom-StringData.ps1
Last active October 8, 2021 10:20
A quick replacement for ConvertFrom-StringData which supports ordered dictionary output
function ConvertFrom-StringData {
<#
.FORWARDHELPTARGETNAME Microsoft.PowerShell.Utility\ConvertFrom-StringData
#>
[CmdletBinding()]
param (
[Parameter(Mandatory, Position = 1, ValueFromPipeline)]
[string]$StringData,
@indented-automation
indented-automation / ConvertTo-X509Certificate.ps1
Last active February 15, 2021 20:33
Import-Certificate.ps1
using namespace System.Management.Automation
using namespace System.Security.Cryptography.X509Certificates
function ConvertTo-X509Certificate {
<#
.SYNOPSIS
Convert a Base64 encoded certificate (with header and footer) to an X509Certificate object.
.DESCRIPTION
ConvertTo-X509Certificate reads a Base64 encoded certificate string or file and converts it to an X509Certificate object.
.EXAMPLE
@indented-automation
indented-automation / Get-TaskStartDate.ps1
Last active August 24, 2022 09:12
Gets the next date
function Get-TaskStartDate {
<#
.SYNOPSIS
Get a start date from a string expression.
.DESCRIPTION
Finds the start date from a string expression.
.EXAMPLE
Get-TaskStartDate -Day '1st Monday'
function Test-RpcPort {
<#
.SYNOPSIS
Enumerates and tests connectivity to the RPC ports on the target server.
.DESCRIPTION
Enumerates and tests connectivity to the RPC ports on the target server.
Rebuilt from https://gallery.technet.microsoft.com/Test-RPC-Testing-RPC-4396fcda
#>
@indented-automation
indented-automation / Split-DistinguishedName.ps1
Last active February 7, 2025 17:27
Split an AD DN into different parts
function Split-DistinguishedName {
<#
.SYNOPSIS
Split a distinguishedName into named pieces.
.DESCRIPTION
Split a distinguishedName into Name, ParentDN, ParentName, and DomainComponent.
.EXAMPLE
Split-DistinguishedName 'OU=somewhere,DC=domain,DC=com'
function Get-ADAttributeAlias {
<#
.SYNOPSIS
Gets the names of the aliased attributes from the ActiveDirectory module.
.DESCRIPTION
Users reflection to discover the names of the attribute aliases available to filters.