Skip to content

Instantly share code, notes, and snippets.

View jschlackman's full-sized avatar

James Schlackman jschlackman

View GitHub Profile
@jschlackman
jschlackman / Remediate Network Location Awareness.xml
Last active October 5, 2023 15:09
Checks if the current machine has at least one active network connection that is Domain Authenticated. If it doesn't, restart the Network Location Awareness service.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Author>[email protected]</Author>
<Description>Restarts the Network Location Awareness following an LDAP authentication failure (typically due to a DC being temporarily unavailable during an update cycle)</Description>
<URI>\Remediate Network Location Awareness</URI>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
# Name: Remove-dbutil.ps1
# Author: James Schlackman
# Last modified: May 4, 2021
# Remediation of CVE-2021-21551 / DSA-2021-088
# Implements remediation Step 1, Option 2 from
# https://www.dell.com/support/kbdoc/en-us/000186019/dsa-2021-088-dell-client-platform-security-update-for-dell-driver-insufficient-access-control-vulnerability
$CheckPaths = (Get-ChildItem -Attributes d -Path $env:SystemDrive\Users | Select -Property @{Label="FullName";Expression={$($_.Fullname) + "\AppData\Local\Temp"}}) + (Get-Item -Path $env:SystemRoot\Temp | Select FullName)
<#
.SYNOPSIS
Toggles the status of self-service purchase for eligible Microsoft 365 products.
.DESCRIPTION
Gets the list of Microsoft 365 product licenses that are available for self-service purchase and allows the status of selected products to be toggled (e.g. Enabled set to Disabled and vice-versa)
Author: James Schlackman <[email protected]>
Last Modified: March 6 2025
# Name: Remove-DisabledUnifiedGroupOwners.ps1
# Author: James Schlackman
# Last Modified: Oct 18 2023
#
# Checks all Office 365 Unified Groups for owners that have their accounts disabled, and removes them as owner.
# If the group would be left with no owners, find the first non-disabled member and promote them.
#Requires -Modules ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement
<#
.SYNOPSIS
Sets up a daily shadow copy on a specified drive.
.DESCRIPTION
Sets up a daily shadow copy on a specified drive, which enables 'Previous Versions' functionality on non-server editions of Windows.
The maximum shadow copy storage space will be set to 10% to accomodate storage needed for the shadow copies.
Optionally also enables System Restore functionality.
@jschlackman
jschlackman / CIDR.txt
Last active November 20, 2020 19:03
IP ranges for public IP address space (excluding RFC1918 private addresses)
0.0.0.0/5
8.0.0.0/7
11.0.0.0/8
12.0.0.0/6
16.0.0.0/4
32.0.0.0/3
64.0.0.0/2
128.0.0.0/3
160.0.0.0/5
<#
.SYNOPSIS
Gets the public TLS certificate from a remote server.
.DESCRIPTION
Connects to a specified server and port and initiates a TLS handshake to retrieve the remote public certificate.
Optionally also returns a PEM-encoded version of the certificate.
Adapted from script by Rob VandenBrink at https://isc.sans.edu/forums/diary/Assessing+Remote+Certificates+with+Powershell/20645/
@jschlackman
jschlackman / ReconnectHome.vbs
Created July 23, 2020 16:26
Reconnects missing home drive based on AD attributes (in case environment variables are blank). Trigger this when your client VPN connects to ensure that the home drive is mapped if the user was disconnected at logon time.
Dim objNetwork, strRemoteShare
Set objNetwork = CreateObject("WScript.Network")
Dim oFileSys
Set oFileSys = CreateObject("Scripting.FileSystemObject")
' Read home drive info directly from AD in case environment variables are blank
Dim objSysInfo, objUser
Set objSysInfo = CreateObject("ADSystemInfo")
' Get currently logged in user
# Name: Disable-ExpiredAccounts.ps1
# Author: James Schlackman
# Last Modified: June 5 2020
# Queries AD for any expired account that is not already disabled, and disables it.
Get-ADUser -LDAPFilter "(&(accountExpires<=$((Get-Date).ToFileTime()))(!accountExpires=0)(!userAccountControl:1.2.840.113556.1.4.803:=2))" | Disable-ADAccount
# Name: Cleanup-UngroupedDriverPackages.ps1
# Author: James Schlackman
# Last Modified: Sep 10 2021
# Gets details of all driver packages in WDS that are not assigned to a driver group, and optionally removes them.
# Must be run on the target WDS server with administrative privileges.
$AllPackageIDs = (wdsutil /get-alldriverpackages | Select-String "^Id: ({.*})" | ForEach-Object {$_.Matches.Groups[1].Value})
Write-Output "Total driver packages on server: $($AllPackageIDs.Count)"