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 / bam.ps1
Created September 5, 2023 12:02
Background Activity Moderator
Add-Type -TypeDefinition @'
using System.Runtime.InteropServices;
using System.Text;
public class Native
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern uint QueryDosDevice(
string lpDeviceName,
StringBuilder lpTargetPath,
Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;
using System.Text;
public class UserProfile
{
[DllImport("userenv.dll")]
public static extern int CreateProfile(
[MarshalAs(UnmanagedType.LPWStr)] string pszUserSid,
#Requires -Modules PSKoans
Describe "Register-Advice" {
BeforeAll {
$module = @{
ModuleName = 'PSKoans'
}
}
Context "Profile Folder/File Missing" {
@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.
@indented-automation
indented-automation / ADDns.ps1
Created July 21, 2022 14:30
This is a mess. Needs major refactoring.
##############################################################################################################################################################
# IANA #
##############################################################################################################################################################
#
# Address family
#
New-Enum -ModuleBuilder $IndentedDnsMB -Name "Indented.Dns.IanaAddressFamily" -Type "UInt16" -Members @{
IPv4 = 1; # IP version 4
# Chocolatey must be installed on all nodes which intend to use it
https://chocolatey.org/install#individual
# Make a folder called DhcpDaemon
New-Item DhcpDaemon -ItemType Directory
# Inside that folder, make a folder called Tools
# This will hold your installation files and an install script
New-Item DhcpDaemon\tools -ItemType Directory
# Make an install script
@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 / 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.