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.
#>
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
@indented-automation
indented-automation / Watch-WinEvent.ps1
Created July 13, 2022 19:07
Event log subscriber
function Watch-WinEvent {
<#
.SYNOPSIS
Watch for events matching a query in the event log.
.DESCRIPTION
Watch for events matching a query in the event log.
#>
@indented-automation
indented-automation / SystemTray.ps1
Created July 22, 2022 10:36
Functions to allow changes to the visibility of icons in the system tray.
enum Visibility : byte {
Default = 0
Hide = 1
Show = 2
}
function Convert-CeaserCipher {
<#
.SYNOPSIS
Convert a string to and from a ceaser cipher (ROT-13) encoding.
filter Write-String {
<#
.SYNOPSIS
Write a string representation of an object.
.DESCRIPTION
Write-String creates formatted string representations of an input object.
.INPUTS
System.Object
.EXAMPLE
Get-Process | Write-String
function New-ConsoleMenu {
param (
[ScriptBlock]$ScriptBlock,
[String]$Title,
[String]$Prompt,
[Object]$Default,
@indented-automation
indented-automation / New-DynamicParameter.ps1
Last active August 11, 2023 22:46
New-DynamicParameter
function New-DynamicParameter {
<#
.SYNOPSIS
Create a new dynamic parameter object for use with a dynamicparam block.
.DESCRIPTION
New-DynamicParameter allows simplified creation of runtime (dynamic) parameters.
.EXAMPLE
New-DynamicParameter Name -DefaultValue "Test" -ParameterType "String" -Mandatory -ValidateSet "Test", "Live"
.EXAMPLE
New-DynamicParameter Name -ValueFromPipelineByPropertyName
@indented-automation
indented-automation / Get-InstalledSoftware.ps1
Last active August 11, 2023 22:35
Get-InstalledSoftware
function Get-InstalledSoftware {
<#
.SYNOPSIS
Get all installed from the Uninstall keys in the registry.
.DESCRIPTION
Read a list of installed software from each Uninstall key.
This function provides an alternative to using Win32_Product.
.EXAMPLE
Get-InstalledSoftware
@indented-automation
indented-automation / Get-CommandSource.ps1
Last active August 11, 2023 22:34
View the source for a command
function Get-CommandSource {
param (
[Parameter(Mandatory)]
[String]$Name
)
try {
$commandInfo = Get-Command $Name
if ($commandInfo -is [System.Management.Automation.AliasInfo]) {
$commandInfo = $commandInfo.ResolvedCommand
using namespace System.Net.Sockets; using namespace System.IO
function Watch-StarWars {
[CmdletBinding()]
param ( )
try {
$tcpClient = [TcpClient]::new()
$tcpClient.Connect('towel.blinkenlights.nl', 23)