Skip to content

Instantly share code, notes, and snippets.

View jschlackman's full-sized avatar

James Schlackman jschlackman

View GitHub Profile
@jschlackman
jschlackman / isolated-printers.config
Last active September 28, 2018 22:16
IOS configuration snippet showing how to allow an otherwise isolated guest VLAN 99 (172.16.0.0/16) to be able to communicate to IP printers on VLAN 1 (10.0.0.0/8) with enough access for Windows to be able to automatically configure them by IP address.
object-group network Guest_Access_Printers 
  range 10.0.50.51 10.0.50.61
  host 10.0.50.90
!
interface GigabitEthernet0/1.99
encapsulation dot1Q 99
ip address 172.16.0.1 255.255.0.0
ip access-group Guest_Restrictions in
!
@jschlackman
jschlackman / Send-Inventory.ps1
Last active October 13, 2018 23:25
Creates a basic hardware inventory of the current computer from WMI and emails it as a formatted HTML report. I typically use this to create a specification summary for old laptops that have been removed from production use and that are being prepared for resale.
# Name: Send-Inventory.ps1
# Author: James Schlackman
# Last Modified: Oct 13 2018
#
# Creates a basic hardware inventory of the current computer from WMI and emails it as a formatted HTML report.
# Configure your mail relay and destination email address here
$MailRelay = "smtp.contoso.com"
$FromAddress = "youraccount@contoso.com"
# Name: Update-WorkstationUsers.ps1
# Author: James Schlackman
# Last Modified: Oct 17 2018
#
# Updates a given AD group with a list of users who have been assigned to a workstation via the computer account's managedBy attribute
# Group to update
$userGroup = "CN=Workstation Users,OU=Mail Groups,DC=contoso,DC=com"
# Get all users assigned to an active computer via the computer account's managedBy attribute
# Name: ProvisionedApps-Remediation.ps1
# Author: James Schlackman
# Last Modified: Nov 05 2018
#
# Check for the presence of unwanted provisioned apps and removes them from the current system image if found.
#
# This does NOT remove them for any current user who has already logged in, since provisioned apps
# are installed again at the user-level at first login. This will only prevent them from appearing
# for new users.
# Name: Set-netbootGUID.ps1
# Author: James Schlackman
# Last Modified: Nov 04 2018
#
# Sets the netbootGUID attribute for computers in AD, for use with Windows Deployment Server.
# Reads a CSV and adds a netbootGUID to existing computers where the attribute is blank.
#
# For computer names that appear in the CSV but are not present in AD, a Computer object is
# prestaged so WDS can auto-name new computers with a matching MAC address.
# Name: Convert-GeforceOverlayScreenshots.ps1
# Author: James Schlackman
# Last Modified: Nov 20 2018
#
# Looks for PNG files in subfolders of the output folder used by GeForce Overlay, saves them
# as JPEG files in the user's Screenshots folder (in subfolders by game name) and then moves
# the PNG files to the Recycle Bin.
$overlayFolder = "$([environment]::GetFolderPath("MyVideos"))\Captures"
$screenshotFolder = "$([environment]::GetFolderPath("MyPictures"))\Screenshots"
# Retrieves the first MX record for a given email address (usually the one with the lowest preference number in DNS)
function Get-MailAddressMx {
[cmdletbinding()]
param([Parameter(Mandatory=$true, ValueFromPipeline=$true)] [string]$MailAddress)
process{
$mailDomain = $MailAddress.Substring($MailAddress.IndexOf('@') + 1)
If ($mailDomain) {
$mailMx = Resolve-DnsName -Type MX -Name $mailDomain
If ($mailMx) {
# Name: Config-SystemRestore.ps1
# Author: James Schlackman
# Last Modified: May 1 2018
#
# Checks if System Restore is enabled for the system drive (normally C:). If not, turn it on.
# Also ensures the usage quota for system restore points is set to at least 5% of disk space (minimum 10GB).
$RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients'
$SysDrive = (Get-Volume | Where-Object {$_.DriveLetter -eq "$($env:SystemDrive[0])"})
@jschlackman
jschlackman / Email-DormantAccountDetails.ps1
Last active June 4, 2020 20:05
Run this using a Scheduled Task to send email reports of enabled but dormant AD user accounts.
# Name: Email-DormantAccountDetails.ps1
# Author: James Schlackman
# Last Modified: June 4 2020
# Looks for enabled AD accounts that meet one of the following criteria:
# - Last used more than x days ago
# - Created more than x days ago and have never been used
# - Account expired date has passed
#
# Emails an HTML report of any accounts found to a specified address.
# Name: Get-ADAccessDetails.ps1
# Author: James Schlackman
# Last Modified: May 4 2023
#
# Audits all enabled users in specified OUs and outputs the date they last logged in, when they last changed
# their password, when their password expires, and whether they are a member of any AD administrator groups.
$checkOUs = "OU=People,DC=contoso,DC=com","OU=Robots,DC=contoso,DC=com"
$AuditUsers = @()