Skip to content

Instantly share code, notes, and snippets.

View liveaverage's full-sized avatar
⚙️

J.R. Morgan liveaverage

⚙️
View GitHub Profile
@liveaverage
liveaverage / getadsmtp.py
Last active November 16, 2021 16:06
Python alternative to getadsmtp.pl; Runs faster and performs the same AD query for valid SMTP recipients. Credits noted in the comments.
#!/usr/bin/env python
#Credits: Marc Smith, http://marcitland.blogspot.com/2011/02/python-active-directory-linux.html
# DarkPixel, https://github.com/darkpixel/scripts/blob/master/getadsmtp.py
# JR, http://liveaverage.com
import sys, ldap, argparse
import ldap.modlist as modlist
from ldap.controls import SimplePagedResultsControl
@liveaverage
liveaverage / Bulk-AD-Reverse-DNS-NS-Delete
Created January 16, 2013 18:29
Powershell wrapper for dnscmd operations. Detects NS resource records in reverse lookup zones and generates commands for automatic removal.
$ds = "dns.yourdomain.com"
$nd = "node.to.delete.yourdomain.com"
function Get-RevZones ($ds)
{
$header = @("zonename","type","storage","prop","lookup")
$raw = (dnscmd $ds /enumzones /reverse) | ?{$_ -match "Rev"} | %{$_ -replace "^."} | %{$_ -replace '\s+', ','}
return ($raw | ConvertFrom-Csv -Header $header)
}
@liveaverage
liveaverage / check_DFS_backlog.ps1
Last active December 20, 2019 08:29
Local Check_MK Powershell check that dynamically populates DFS Backlog Counts for all replicated folder groups. Outputs individual DFS backlog counts (one per replication direction) and performance data for individual replicated folder groups, along with a 'global' DFS Backlog count aggregating the status of all replication folder groups. The co…
$computer = [System.Net.Dns]::GetHostName()
$Computer = [System.Net.Dns]::GetHostName()
# Fix issue with console text wrap:
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 300)
$OK = 0
$Warn = 1
$Crit = 2
$Unk = 3
@liveaverage
liveaverage / mod_radacct.py
Last active August 29, 2015 13:56
Cisco CDA (formerly Cisco AD Agent) RADIUS Accounting
import random, socket, sys, logging
import pyrad.packet
from pyrad.client import Client
from pyrad.dictionary import Dictionary
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
#Logger Console Handler
@liveaverage
liveaverage / Sync-Dhcp-Reservations.ps1
Last active July 3, 2023 17:23
Sync-Dhcp-Reservations.ps1
<#
.Synopsis
Synchronizes DHCP reservations to all or select authorized DHCP servers in a given domain.
.Description
This script utilizes a user-specified source (master) DHCP server and synchronizes
all or some scope reservations between other, authorized DHCP servers for a given domain.
Netsh commands can be generated for manual execution or executed automatically.
.Parameter Source
@liveaverage
liveaverage / check_dhcp_all_pools.sh
Created July 29, 2014 13:25
Different take on Lars Michelsen's original plugin/script to accommodate monitoring of all available DHCP scopes on your monitored Windows server. You no longer need to add separate service definitions to monitor all available scopes.
#! /bin/bash
# ##############################################################################
# check_dhcp_all_pools.sh - Nagios plugin
#
# This script querys a MS Windows DHCP-Server via SNMP v2 to fetch informations about the given DHCP-Pool.
#
# Copyright (C) 2006, 2007 Lars Michelsen <[email protected]>,
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@liveaverage
liveaverage / check_DNS_Scavenge.ps1
Created July 29, 2014 13:47
Local Check_MK: check_DNS_Scavenge.ps1
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size(500,300)
$server = $env:COMPUTERNAME
$global:debug = ""
$global:n_stat = ""
$global:n_stattext = ""
@liveaverage
liveaverage / check_Exchange_SG_LogTruncate.ps1
Created July 29, 2014 13:48
Local Check_MK: check_Exchange_SG_LogTruncate.ps1
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size(900,900)
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
$check_name = "Exchange_SG_LogTrunc"
$OK = 0
$Warn = 1
$Crit = 2
$Unk = 3
@liveaverage
liveaverage / check_Exchange_StorageGroups.ps1
Created July 29, 2014 13:50
Local Check_MK: check_Exchange_StorageGroups.ps1
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size(900,900)
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
$check_name = "Exchange_SG_CopyStatus"
$OK = 0
$Warn = 1
@liveaverage
liveaverage / Execute-Local-64.bat
Created July 29, 2014 14:08
Local Check_MK: Bulk execute local checks in 64-bit consoles from x86 Check_MK
@echo off
REM Note that SysNative is available on x86 2008, and on x86 2003 with KB942589 applied
set CONSOLE_WIDTH=500
CD %ProgramFiles(x86)%\check_mk\local-64
FOR /R %%X IN ("*") DO ( %WINDIR%\SysNative\windowspowershell\v1.0\powershell.exe -File "%%X")