Skip to content

Instantly share code, notes, and snippets.

View jschlackman's full-sized avatar

James Schlackman jschlackman

View GitHub Profile
<#
Name: Get-UserExchangeGroupMembership.ps1
Author: James Schlackman
Last Modified: May 21 2024
Displays all Exchange Online distribution lists and Office 365 groups that a specified user is a member of,
and optionally removes them from any groups that are not synced from on-prem AD.
#>
#Requires -Modules ExchangeOnlineManagement
# Remove the erroneous temporary flag from any GPO files on the current DC. Fixes issues listed in the DFSR diagnotic log as:
#
# "DFS Replication does not replicate certain files in the replicated folders listed above because they have temporary attribute set, or they are symbolic links."
Get-ChildItem "$env:SystemRoot\SYSVOL\domain\Policies" -recurse | ForEach-Object -process {if (($_.attributes -band 0x100) -eq 0x100) {$_.attributes = ($_.attributes -band 0xFEFF)}}
<#
.SYNOPSIS
Outputs an HTML listing of all files in a specified folder, grouped in order by subfolder.
.DESCRIPTION
Enumerates all files and subfolders within a specified path and creates an HTML report listing name, file type, size, created date, and modified date.
Author: James Schlackman <[email protected]>
Last Modified: March 6 2025
# Name: Get-DirectoryAccessDetails.ps1
# Author: James Schlackman
# Last Modified: Oct 17 2023
#
# Audits all enabled users in specified on-prem AD OUs and combines with it with enabled users from Entra ID.
# Outputs a combined list showing which accounts are federated/on-prem only/cloud only along with details of
# the most recent date they logged in (either on-prem or cloud, whichever is later), when they last changed
# their password, when the account was created, and which AD admin and Entra roles they are assigned (if any).
#
# Last sign in date for Entra requires an Entra ID Premium license.
# Name: Get-AADAccessDetails.ps1
# Author: James Schlackman
# Last Modified: May 3 2023
#
# Audits all enabled users in Azure AD and outputs the date they last logged in, when they last changed
# their password, when the account was created, and which Azure AD roles they are assigned (if any).
#
# NOTE: Azure AD only began storing account creation dates in June 2018. CreatedDateTime will be blank
# for accounts created before that time.
#
@jschlackman
jschlackman / Email Old File Details.xml
Created November 29, 2022 15:49
Searches for files that were created or modified more than a certain number of days ago and creates/emails an HTML report of any results.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-11-29T12:00:00</Date>
<Author>[email protected]</Author>
<Description>Searches for files that were created or modified more than a certain number of days ago and creates/emails an HTML report of any results.</Description>
<URI>\Email Old File Details</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<#
.SYNOPSIS
Downloads and installs the Windows 10 22H2 enablement package.
.DESCRIPTION
Downloads and installs the Windows 10 22H2 enablement package for machines not managed by a patch management system that supports feature updates natively (e.g. Windows Update, WSUS, Intune).
Requires Windows 10 build 2004 through 21H2.
Author: James Schlackman <[email protected]>
@jschlackman
jschlackman / Save-Download.ps1
Created May 18, 2022 16:14 — forked from MattHodge/Save-Download.ps1
Save-Download.ps1
function Save-Download {
<#
.SYNOPSIS
Given either the result of WebResponseObject or a Uri, will download the file to disk without having to specify a name.
.DESCRIPTION
Given either the result of WebResponseObject or a Uri, will download the file to disk without having to specify a name.
.PARAMETER WebResponse
A WebResponseObject from running an Invoke-WebRequest on a file to download.
.PARAMETER Uri
Uri of a file to download in lieu of supplying a WebResponseObject.
@jschlackman
jschlackman / Set-DellAdminPwd.ps1
Created March 31, 2022 20:40
Function that uses the Dell Command Powershell Provider to set the initial admin password and prevent further BIOS changes from being made without the password being supplied.
# Name: Set-DellAdminPwd.ps1
# Author: James Schlackman
# Last Modified: March 31 2022
# Function that uses the Dell Command Powershell Provider to set the initial admin password and
# prevent further BIOS changes from being made without the password being supplied.
# https://www.dell.com/support/home/en-us/product-support/product/command-powershell-provider/docs
#Requires -Modules DellBIOSProvider
@jschlackman
jschlackman / Disable Idle Power Saving on Realtek USB Ethernet.xml
Created February 16, 2022 20:27
Disable Idle Power Saving on Realtek USB Ethernet adapters to prevent random network dropouts on Dell WD15 and WD19 docks
<?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>Disable Idle Power Saving on Realtek USB Ethernet adapters to prevent random network dropouts on Dell WD-series docks</Description>
<URI>\Disable Idle Power Saving on Realtek USB Ethernet</URI>
</RegistrationInfo>
<Triggers>
<RegistrationTrigger>
<Enabled>true</Enabled>