Skip to content

Instantly share code, notes, and snippets.

View indented-automation's full-sized avatar

Chris Dent indented-automation

View GitHub Profile
function Update-RegistryFile {
<#
.SYNOPSIS
Updates a registry file.
.DESCRIPTION
Line break and certain characters will not import from standard registry files (even if export works).
This function replaces any entry with line breaks with a hex value representing the string.
#>
@indented-automation
indented-automation / Send-Syslog.ps1
Created September 17, 2019 17:44
Send a message to a SysLog instance
function Send-Syslog {
param (
[Parameter(Mandatory, ValueFromPipeline)]
[String]$Message,
[String]$LogLevel = 'Information',
[Parameter(Mandatory)]
[IPAddress]$IPAddress,
function ConvertTo-TableFormat {
<#
.SYNOPSIS
Rebuild an object based on the Format Data for the object.
.DESCRIPTION
Allows an object to be rebuilt based on the view data for the object. Uses Select-Object to create a new PSCustomObject.
#>
[CmdletBinding()]
param (
using namespace System.Collections.Generic; using namespace System.Text
Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;
using System.Text;
public class WindowTools
{
public delegate bool EnumWindowsProc(IntPtr hWnd, int lParam);
function Measure-ChildItem {
<#
.SYNOPSIS
Recursively measures the size of a directory.
.DESCRIPTION
Recursively measures the size of a directory.
Measure-ChildItem uses win32 functions, returning a minimal amount of information to gain speed. Once started, the operation cannot be interrupted by using Control and C. The more items present in a directory structure the longer this command will take.
This command supports paths longer than 260 characters.
using namespace System.Net.Sockets; using namespace System.IO
function Watch-StarWars {
[CmdletBinding()]
param ( )
try {
$tcpClient = [TcpClient]::new()
$tcpClient.Connect('towel.blinkenlights.nl', 23)
function ConvertTo-DataTable {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
[Object]$InputObject
)
begin {
$dataTable = [System.Data.DataTable]::new()
}
enum NameType {
DistinguishedName = 1
CanonicalName
NT4
DisplayName
DomainSimple
EnterpriseSimple
Guid
Unknown
UserPrincipalName
function Get-ArgumentCompleter {
<#
.SYNOPSIS
Get custom argument completers registered in the current session.
.DESCRIPTION
Get custom argument completers registered in the current session.
By default Get-ArgumentCompleter lists all of the completers registered in the session.
.EXAMPLE
Get-ArgumentCompleter
function ConvertTo-NormalizedString {
<#
.SYNOPSIS
Attempts to replace diacritics within a the input string.
.DESCRIPTION
Uses String.Normalize to attempt to replace diacritic characters within a string.
#>
[CmdletBinding()]
param (