Skip to content

Instantly share code, notes, and snippets.

View indented-automation's full-sized avatar

Chris Dent indented-automation

View GitHub Profile
$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 August 3, 2021 08:13
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.
using module ActiveDirectory
using namespace System.Reflection
function Convert-ADFilter {
<#
.SYNOPSIS
Converts PowerShell-style filters used by the AD module into LDAP filters.
.DESCRIPTION
Convert-ADFilter uses the QueryParser from the AD module to convert PowerShell-style filters into LDAP
@indented-automation
indented-automation / Export-EventLog.ps1
Created November 29, 2019 18:27
Export an event log to an evtx file.
function Export-EventLog {
<#
.SYNOPSIS
Export an event log to a saved event log file.
.DESCRIPTION
Export an event log, and it's messages, to a named event log file.
.EXAMPLE
Get-WinEvent -ListLog Application | Export-EventLog
function Invoke-NativeCommand {
<#
.SYNOPSIS
Invoke a native command (.exe) as a new process.
.DESCRIPTION
Invoke-NativeCommand executes an arbitrary executable as a new process. Both the standard
and error output streams are redirected.
Error out is written as a single non-terminating error. ErrorAction can be used to raise