Skip to content

Instantly share code, notes, and snippets.

View jschlackman's full-sized avatar

James Schlackman jschlackman

View GitHub Profile
# 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)}}
# Name: Get-HtmlFolderReport.ps1
# Author: James Schlackman
# Last Modified: October 18 2023
#
# Outputs an HTML listing of all files in a specified folder, grouped in order by subfolder
Param(
[Parameter(Mandatory)] [String] $SearchPath,
[Parameter()] [String] $OutputPath = "$((Get-Date).ToString("yyMMdd")) $((Get-Item -Path $SearchPath).Name).html"
)
# 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>james@schlackman.org</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>
# Downloads and installs the Windows 10 21H2 enablement package for machines not managed by Windows Update or WSUS.
# Requires Windows 10 2004, 20H2, or 21H1
# https://support.microsoft.com/en-us/topic/kb5003791-update-to-windows-10-version-21h2-by-using-an-enablement-package-8bc077be-18d7-4aac-81ce-6f6dad2cd384
# Check if Windows is currently running a valid build number to receive the enablement package
If ([Environment]::OSVersion.Version.Build -in 19041..19043) {
# Get OS architecture
$arch = If (!$env:PROCESSOR_ARCHITEW6432) {$env:PROCESSOR_ARCHITECTURE}
@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>james@schlackman.org</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>
@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>james@schlackman.org</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>