Skip to content

Instantly share code, notes, and snippets.

View SMSAgentSoftware's full-sized avatar

Trevor Jones SMSAgentSoftware

View GitHub Profile
@SMSAgentSoftware
SMSAgentSoftware / Delete-DeviceRecords.ps1
Last active May 6, 2024 22:29
Deletes device records in AD / AAD / Intune / Autopilot / ConfigMgr. Useful for Autopilot test deployments.
[CmdletBinding(DefaultParameterSetName='All')]
Param
(
[Parameter(ParameterSetName='All',Mandatory=$true,ValueFromPipelineByPropertyName=$true,ValueFromPipeline=$true)]
[Parameter(ParameterSetName='Individual',Mandatory=$true,ValueFromPipelineByPropertyName=$true,ValueFromPipeline=$true)]
[string[]]$ComputerName,
[Parameter(ParameterSetName='All')]
[switch]$All = $True,
[Parameter(ParameterSetName='Individual')]
[switch]$AD,
@SMSAgentSoftware
SMSAgentSoftware / New-WPFMessageBox
Last active April 28, 2024 11:24
PowerShell function to display a customizable WPF message box / window
Function New-WPFMessageBox {
# For examples for use, see my blog:
# https://smsagent.wordpress.com/2017/08/24/a-customisable-wpf-messagebox-for-powershell/
# CHANGES
# 2017-09-11 - Added some required assemblies in the dynamic parameters to avoid errors when run from the PS console host.
# Define Parameters
[CmdletBinding()]
@SMSAgentSoftware
SMSAgentSoftware / Get-DeliveryOptimizationDownloadHistory.ps1
Last active April 25, 2024 15:22
Converts completed download job entries from the Delivery Optimization Log into useable PS objects
# Converts completed download job entries from the Delivery Optimization Log into useable PS objects
$DOLogsOutPut = Get-DeliveryOptimizationLog
$CompletedDownloads = $DOLogsOutPut | Where-Object { $_.Function -Like "*::_InternalTraceDownloadCompleted" }
# Could also be this if nothing returned from previous line:
#$CompletedDownloads = $DOLogsOutPut | Where-Object { $_.Function -Like "*::TraceDownloadCompletedImpl" }
# Custom classes to contain put the parsed data into
class bytes {
[int]$File
[int]$CDN
@SMSAgentSoftware
SMSAgentSoftware / Get-WindowsVersion.ps1
Last active April 21, 2024 19:47
Finds the Windows version including Edition, Version and OS Build numbers for local or remote computers
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$false,
ValueFromPipelineByPropertyName=$true,
ValueFromPipeline=$true
)]
[string[]]$ComputerName = $env:COMPUTERNAME
)
@SMSAgentSoftware
SMSAgentSoftware / New-WoodyRestartNotification.ps1
Created May 11, 2020 08:54
Creates a Toy Story-themed restart notification in top left of primary screen
Add-Type -AssemblyName PresentationFramework,System.Windows.Forms
# Set screen working area, and start and finish location of the window 'top' property (for animation)
$workingArea = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea
$TopStart = $workingArea.Top - 449
$TopFinish = $workingArea.Top + 10
[xml]$Xaml = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@SMSAgentSoftware
SMSAgentSoftware / New-CustomToastNotification.ps1
Last active April 21, 2024 11:41
Create your own toast notification with WPF and PowerShell
# Demo script to display a custom 'toast' notification
# Load required assemblies
Add-Type -AssemblyName PresentationFramework, System.Windows.Forms
# User-populated variables
$WindowHeight = 140
$WindowWidth = 480
$Title = "New Blog Post by SMSAgent!"
$Text = "Trevor Jones has posted a new blog: Create a custom toast notification with WPF and PowerShell. Click here to read."
@SMSAgentSoftware
SMSAgentSoftware / New-RemoteToastNotification.ps1
Created June 11, 2019 12:59
Displays a toast notification on a remote computer
$Sender = "Trevor Jones"
$Message = "Hey buddy - ready for lunch?"
$RemoteComputer = "PC001"
Function New-ToastNotification {
Param($Sender,$Message)
# Required parameters
$AudioSource = "ms-winsoundevent:Notification.Default"
$HeaderFormat = "ImageAndTitle" # Choose from "TitleOnly", "ImageOnly" or "ImageAndTitle"
@SMSAgentSoftware
SMSAgentSoftware / New-TrayIconCustomContextMenu.ps1
Created September 25, 2019 21:49
Script to create a system tray icon with a custom Windows 10-style context menu
##################################################################
## PS Script to create a custom WPF content menu for a tray app ##
##################################################################
# Add assemblies
Add-Type -AssemblyName System.Windows.Forms,PresentationFramework
# Create a WinForms application context
$appContext = New-Object System.Windows.Forms.ApplicationContext
# User-context script to set the Language List
# Language codes
$PrimaryLanguage = "en-GB"
$SecondaryLanguage = "en-US"
$PrimaryInputCode = "0809:00000809"
$SecondaryInputCode = "0409:00000409"
# Set preferred languages
$NewLanguageList = New-WinUserLanguageList -Language $PrimaryLanguage
# Admin-context script to set the administrative language defaults, system locale and install optional features for the primary language
# Language codes
$PrimaryLanguage = "en-GB"
$SecondaryLanguage = "en-US"
$PrimaryInputCode = "0809:00000809"
$SecondaryInputCode = "0409:00000409"
$PrimaryGeoID = "242"
# Enable side-loading