Skip to content

Instantly share code, notes, and snippets.

[cmdletbinding()]
Param (
[Parameter(Mandatory=$true)]$domain
)
#Import Active Directory module
Import-Module ActiveDirectory
#Initialize arrays to store results
$results = @()
$zoneresults = @()
@abix-
abix- / Check-Queues.ps1
Last active August 29, 2015 14:24
How can I monitor and purge large MSMQ queues?
#If the number of messages in a queue are above this value, the queue will be purged.
$threshold = 500000
#Logging configuration
$path = "G:\Jobs"
$logname = "msmq_monitor.log"
$rotation_threshold_mb = 10
function EmailResults($computername,$queuename,$messagecount) {
$global:smtpserver = "smtpserver.domain.local"
@abix-
abix- / cvi.ps1
Last active August 29, 2015 14:24
How can I login to vSphere and PowerCLI faster?
function cvi([switch]$client) {
#Read vcenters.csv and draw menu
$vcenters = Import-Csv "C:\Scripts\vcenters.csv"
Write-Host "Select a server from the list"
for($i = 1; $i -lt $vcenters.count + 1; $i++) { Write-Host "[$i] $($vcenters[$i-1].vCenter)" }
#Switch $option to determine selected vCenter
$option = Read-Host
switch -Regex ($option) {
"\d" {
vCenter Credentials
vcenter-a domain.local\credentials
old-vcenter sub.domain.local\credentials
Vcenter-reallylongname domain.local\credentials
<#
.SYNOPSIS
Collect configuration metrics for a VMHost, Cluster, Datacenter, or vCenter. For each VM Host found, these metrics are collected:
-Parent object(Cluster, Datacenter)
-Hardware model
-ESXi build
-IP address
-VMs on host
-physical CPUs(pCPU) on host
-virtual CPUs(vCPU) allocated
@abix-
abix- / OneNote.ps1
Last active March 3, 2023 16:51
Converting between OneNote Tables and PowerShell PSObject
function Get-1NotePage {
<#
.SYNOPSIS
Finds the ID of a OneNote page
.DESCRIPTION
http://thebackend.info/powershell/2017/12/onenote-read-and-write-content-with-powershell/
.EXAMPLE
Get-1NotePage -Name "PowerShell Test"
#>
[cmdletbinding()]
@abix-
abix- / atlas.ahk
Last active December 6, 2022 00:04
Atlas macros
; https://www.autohotkey.com/docs/Hotkeys.htm
; ^ = Control
; * = Wildcard: Fire the hotkey even if extra modifiers are being held down
; ~ = When the hotkey fires, its key's native function will not be blocked (hidden from the system)
; Click positions assume 1920x1080 resolution
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#MaxThreadsPerHotkey 1
SetDefaultMouseSpeed 0
@abix-
abix- / moe.ahk
Last active December 23, 2021 21:29
; https://www.autohotkey.com/docs/Hotkeys.htm
; ^ = Control
; * = Wildcard: Fire the hotkey even if extra modifiers are being held down
; ~ = When the hotkey fires, its key's native function will not be blocked (hidden from the system)
; Click positions assume 1920x1080 resolution
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#MaxThreadsPerHotkey 1
SetDefaultMouseSpeed 0
; https://www.autohotkey.com/docs/Hotkeys.htm
; ^ = Control
; * = Wildcard: Fire the hotkey even if extra modifiers are being held down
; ~ = When the hotkey fires, its key's native function will not be blocked (hidden from the system)
; Click positions assume 1920x1080 resolution
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#MaxThreadsPerHotkey 2
SetDefaultMouseSpeed 0
function Optimize-DRSSeparateVMs {
<#
.SYNOPSIS
Creates DRS rules to keep similar VMs on separate VMHosts.Existing AntiAffinity rules are removed.
If VMHosts.count is less than or equal to 4, the max VMs per group is count-1. Otherwise count-2
.EXAMPLE
Create DRS rules on MYCLUSTER
Optimize-DRSSeparateVMs -Cluster MYCLUSTER
.EXAMPLE
Create DRS rules on all clusters