Skip to content

Instantly share code, notes, and snippets.

View jschlackman's full-sized avatar

James Schlackman jschlackman

View GitHub Profile
@jschlackman
jschlackman / ConnectWise Access Management webhook payload for Teams.json
Created January 18, 2024 17:52
JSON payload for webhooks sent from ScreenConnect to Teams for the ConnectWise Access Management feature. This is an alternative to the official integration, allowing more flexibility in terms of which requests are forwarded and using more concise and modern adaptive card formatting.
View ConnectWise Access Management webhook payload for Teams.json
{{
"type": "message",
"attachments": [
{{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
View Remove-ADUserAdmins.ps1
# Name: Remove-ADUserAdmins.ps1
# Author: James Schlackman
# Last Modified: Dec 19 2023
# Clear individual non-local (e.g. AD) users from the local administrators group
# Notes:
# - Uses CIM to retrieve local group membership as Get-LocalGroupMember does not work without DC connectivity
# - Must be run in 64-bit PowerShell Host. The LocalAccounts module is not available in 32-bit PowerShell on a 64-bit system.
@jschlackman
jschlackman / Start-ExternalBackup.ps1
Created November 12, 2023 02:01
Runs an external backup executable, logs output, and sends email notifications. This example runs the FastGlacier console application to sync a local folder hierarchy with S3 Glacier storage.
View Start-ExternalBackup.ps1
# Name: Start-ExternalBackup.ps1
# Author: James Schlackman
# Last Modified: Nov 11 2023
# Runs an external backup executable, logs output, and sends email notifications.
Param(
# External backup executable
[Parameter()] [String] $BackupExe = "$env:ProgramFiles\FastGlacier\glacier-con.exe",
# Backup job arguments to pass to executable
View Get-EntraGuestDetails.ps1
# Name: Get-EntraGuestDetails.ps1
# Author: James Schlackman
# Last Modified: Oct 27 2023
#
# Audits guest users in Entra ID, optionally filtered by start and/or end dates for when users were invited to the directory.
#
# Last sign in date for Entra requires an Entra ID Premium license.
#Requires -Modules Microsoft.Graph.Authentication, Microsoft.Graph.Groups, Microsoft.Graph.Users
View Remove-LegacyLAPSData.ps1
# Name: Remove-LegacyLAPSData.ps1
# Author: James Schlackman
# Last Modified: Oct 24 2023
# Clears the legacy LAPS attributes from specified computer accounts in AD. Use this to remove old password
# data from AD once Windows LAPS is deployed and storing password data in Entra ID.
#Requires -Modules ActiveDirectory
param (
View Get-OldADMachines.ps1
# Name: Get-OldADMachines.ps1
# Author: James Schlackman
# Last Modified: Oct 23 2023
# 1. Finds computer accounts that have been inactive for more than specified time period and optionally disables them
# 2. Finds computer accounts that have been disabled for more than specified time period and optionally deletes them
#Requires -Modules ActiveDirectory
Param(
View Get-AzurePrivateIpAddresses.ps1
# Name: Get-AzurePrivateIpAddresses.ps1
# Author: James Schlackman
# Last Modified: Sep 26 2023
#
# Lists all defined network interfaces with their private IPs and VM allocations.
#Requires -Modules Az.Accounts, Az.Compute, Az.Network
Param(
[Parameter()] [String] $AzTenant,
View Get-UserExchangeGroupMembership.ps1
# Name: Get-UserExchangeGroupMembership.ps1
# Author: James Schlackman
# Last Modified: Aug 29 2023
# 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
Param(
View Set-GPOFilesNotTemp.ps1
# 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)}}
View Get-HtmlFolderReport.ps1
# 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"
)