Skip to content

Instantly share code, notes, and snippets.

View jschlackman's full-sized avatar

James Schlackman jschlackman

View GitHub Profile
# Name: Get-ExpiringPasswords.ps1
# Author: James Schlackman
# Last Modified: Sep 28 2017
#
# Checks all enables users in a given OU to see if their password is going to expire during
# a given date range. Exports a list of those affected.
# Useful for finding out who to remind about changing their password before long vacations.
#
Import-Module ActiveDirectory
# Name: Get-VulnerablePasswords.ps1
# Author: James Schlackman
# Last Modified: Sep 28 2017
#
# Checks a CSV of breached email addresses (e.g. from https://haveibeenpwned.com/) and checks if there
# is an enabled user in AD with a matching email address and password that is older than the reported date
# of the breach.
#
Import-Module ActiveDirectory
# Sync-GSuite2SV-Users.ps1
# -----------------------
# Syncs the list of users currently enrolled in 2-step verification in G Suite with an AD group.
# Reading the user list from G Suite requires a working install of the GAM tool (https://github.com/jay0lee/GAM)
# User account used to run script must have write acess to the folder contianing g
#
# Author: James Schlackman
#
# V1.1 - 2017-10-30 - Write last sync time to group for diagnostics
# V1.0 - 2017-10-11 - First version
# Name: Create-BulkRandomPasswords.ps1
# Author: James Schlackman
# Last Modified: Nov 11 2017
#
# Creates a text file containing a bulk number of passwords made up of a specified length of random
# alphanumerics and special characters.
$PassLength = 16
$NumPasswords = 253
$OutputPath = "BulkRandomPasswords.txt"
@jschlackman
jschlackman / Disable-AutomaticallyDetectSettings.ps1
Last active September 5, 2018 20:18 — forked from ReubenBond/Disable-AutomaticallyDetectSettings.ps1
Disable 'Automatically detect settings' in Internet Explorer's proxy settings dialog.
# Disable 'Automatically detect proxy settings' in Internet Explorer.
# Read connection settings from Internet Explorer.
$regKeyPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\"
$conSet = $(Get-ItemProperty $regKeyPath).DefaultConnectionSettings
# Index into DefaultConnectionSettings where the relevant flag resides.
$flagIndex = 8
# Bit inside the relevant flag which indicates whether or not to enable automatically detect proxy settings.
@jschlackman
jschlackman / AADConnect-HideFromDLUsingExtensionAttr.ps1
Last active September 7, 2018 15:54
For organizations that use Azure AD Connect but have never had on-premises Exchange, check msDS-cloudExtensionAttribute1 attribute for the word "hidden" and use that to set msExchHideFromAddressLists in Azure, since the msExchHideFromAddressLists is not present in AD.
New-ADSyncRule `
-Name 'In from AD - Use msDS-cloudExtensionAttribute1 instead of msExchHideFromAddressLists' `
-Identifier '57244c63-9b0d-45bc-a107-3a35b427037d' `
-Description 'Check msDS-cloudExtensionAttribute1 attribute for the word "hidden" and use that to set msExchHideFromAddressLists, since the msExchHideFromAddressLists is not present in AD' `
-Direction 'Inbound' `
-Precedence 50 `
-PrecedenceAfter '00000000-0000-0000-0000-000000000000' `
-PrecedenceBefore '00000000-0000-0000-0000-000000000000' `
-SourceObjectType 'user' `
-TargetObjectType 'person' `
@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.