Skip to content

Instantly share code, notes, and snippets.

View iyre's full-sized avatar

Miles Miller iyre

View GitHub Profile
@iyre
iyre / Export-IconImageManifest.ps1
Created January 25, 2025 07:28
Export an HTML manifest of icons contained in a DLL
# based on https://renenyffenegger.ch/notes/Windows/PowerShell/examples/WinAPI/ExtractIconEx
function Export-IconImageManifest {
param (
[String]$DllPath = "$env:SYSTEMROOT\System32\imageres.dll"
)
if (! (test-path $dllPath)) {
write-output "$dllPath is not a file"
return
}
@iyre
iyre / screen_hz.ahk
Created December 22, 2023 00:48
AutoHotkey script to change the refresh rate of your primary display
#Requires AutoHotkey v2.0
#SingleInstance
A_IconTip := "Change screen refresh rate"
; Based on an AHK v1 script from this Reddit post
; https://www.reddit.com/r/AutoHotkey/comments/qeqhfs/switch_refresh_rate_using_hotkeys/
; Hotkey modifier symbols: #=Win, !=Alt, ^=Ctrl, +=Shift
; Find and set max supported refresh rate for primary monitor
@iyre
iyre / ip_math.ps1
Created January 28, 2023 04:01
powershell ip math
function IpToInt ([ipaddress]$IPAddress) {
$IpBytes = $IPAddress.GetAddressBytes()
if ([BitConverter]::IsLittleEndian) {
[Array]::Reverse($IpBytes)
}
return [BitConverter]::ToUInt32($IpBytes, 0)
}
@iyre
iyre / Set-ADOrgInfo.ps1
Last active November 11, 2021 23:17
update common organizational attributes in active directory using this powershell script
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)][ValidateSet('Title', 'Department', 'Company')]
[string]$AttributeName = (Read-host -Prompt "Which attribute? [Title, Department, Company]"),
[Parameter(Mandatory = $true)][string]$AttributeValueOld = (Read-Host -Prompt "Old value"),
[Parameter(Mandatory = $true)][string]$AttributeValueNew = (Read-Host -Prompt "New value"),
[switch]$NoConfirm
)
begin {}
@iyre
iyre / Test-UserCredential.ps1
Created October 21, 2021 22:08
Test a domain user's credential, perhaps when validating a temporary password.
function Test-UserCredential {
[CmdletBinding()]
[OutputType([bool])]
param (
[pscredential]$Credential
)
begin {
if ($null -eq $Credential) { $Credential = Get-Credential }
$Domain = $Env:USERDOMAIN
@iyre
iyre / Set-DHCPv4SubnetMask.ps1
Created March 25, 2021 15:36
Update the subnet mask for an existing DHCP scope
$ServerName = "CORP-DHCP01"
$ScopeId = "10.10.10.0"
$SubnetMask = "255.255.255.0" #This is the NEW mask that will be applied
$ServerFile = "c:\temp\dhcp_backup.xml"
$ServerFileBackup = "c:\temp\dhcp_backup2.xml"
$ScopeFile = "c:\temp\scope_$ScopeId.xml"
#backup entire server, just in case
Export-DhcpServer -ComputerName $ServerName -Leases -File $ServerFile
$target = read-host -p "Target"
$key = read-host -p "Key"
slmgr $target -ipk $key
@iyre
iyre / bulk_rename.ps1
Last active June 2, 2020 01:13
powershell bulk rename
Get-ChildItem | Where-Object {$_.Name -like "* - *.wav"} | foreach {
Rename-Item $_ -NewName $_.Name.Substring(5) -whatif
}
$target = read-host "Target"
$group = read-host "Group"
$user = read-host "User"
Invoke-Command -ComputerName $target -ScriptBlock {
net localgroup $(args[0]) $(args[1]) /add
#With PS5
#Add-LocalGroupMember -Group $(args[0]) -Member $(args[1])
} -ArgumentList $group,$user
@iyre
iyre / cisco-ap-config.py
Created February 25, 2020 02:23
python telnetlib to configure cisco ios
import getpass
import sys
import telnetlib
import os
# Variables
tacacs = '.tacacslogin'
commandsfile = 'commands.txt'
hostsfile = 'hosts.txt'
verbose = "yes"