Skip to content

Instantly share code, notes, and snippets.

View SMSAgentSoftware's full-sized avatar

Trevor Jones SMSAgentSoftware

View GitHub Profile
@SMSAgentSoftware
SMSAgentSoftware / Export-CMConfigurationItemScripts.ps1
Created February 21, 2017 11:35
Exports all scripts (discovery and remediation) used in all SCCM Compliance Setting Configuration Items
<#
.Synopsis
Exports all scripts (discovery and remediation) used in all SCCM Compliance Setting Configuration Items
.DESCRIPTION
This script connects to the SCCM database to retrieve all Compliance Setting Configuration Items. It then processes each item looking for
discovery and remediation scripts for the current (latest) version. It will export any script found into a directory structure.
.NOTES
Requirements - 'db_datareader' permission to the SCCM SQL database with the account running this script.
Parameters - set the parameters below as required
#>
@SMSAgentSoftware
SMSAgentSoftware / SQLQuery.ps1
Created March 20, 2017 16:22
A custom class for PowerShell 5+ to query a SQL Server
class SQLQuery
{
# Properties
[string]$SQLServer
[string]$Database
[string]$Query
[string]$QueryFile
[string]$Path
[int]$ConnectionTimeout = 5
@SMSAgentSoftware
SMSAgentSoftware / Backup-CMSiteMaintenanceTaskSettings.ps1
Created April 6, 2017 10:56
Backs up ConfigMgr Site Maintenance Task settings from WMI to json files
## Saves ConfigMgr Site Maintenance Task settings from WMI to json files ##
## Should be run on the Primary Site Server ##
## Should be run as administrator ##
[cmdletbinding()]
Param(
[Parameter(Position=0,Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$SiteCode,
[Parameter(Position=1,Mandatory=$True)]
@SMSAgentSoftware
SMSAgentSoftware / Restore-CMSiteMaintenanceTaskSettings.ps1
Last active November 21, 2017 11:02
Restores ConfigMgr Site Maintenance Task Settings backed up using the 'Backup-CMSiteMaintenanceTaskSettings' script
## Restores ConfigMgr Site Maintenance Task settings from json files (backed up using the 'Backup-CMSiteMaintenanceTaskSettings' script ##
## Should be run on the Primary Site Server ##
## Should be run as administrator ##
[cmdletbinding()]
Param(
[Parameter(Position=0,Mandatory=$True)]
[ValidateNotNullorEmpty()]
[string]$SiteCode,
[Parameter(Position=1,Mandatory=$True)]
@SMSAgentSoftware
SMSAgentSoftware / Download-LatestDellDriverPack.ps1
Created April 25, 2017 16:04
Downloads the latest driver pack from Dell for any model or models you specify
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
ValueFromPipeline=$true,
Position=0)]
[String[]]$Model,
[Parameter(Mandatory=$true,
@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 / Get-PatchStatus.ps1
Created May 22, 2017 17:05
Gets the status of software update/s on remote system/s. This is the SINGLE-THREADED version.
# Get-PatchStatus.ps1
# Gets the status of software update/s on remote system/s
#
# The is the SINGLE-THREADED version
#
# Author: Trevor Jones
# May-2017
[CmdletBinding()]
@SMSAgentSoftware
SMSAgentSoftware / Get-PatchStatus.ps1
Created May 22, 2017 17:07
Gets the status of software update/s on remote system/s. This is the MULTI-THREADED version.
# Get-PatchStatus.ps1
# Gets the status of software update/s on remote system/s
#
# The is the MULTI-THREADED version
#
# IMPORTANT: Requires my [BackgroundJob] custom class, available here: http://smsagent.wordpress.com/posh-5-custom-classes/background-job/
#
# Author: Trevor Jones
# May-2017
@SMSAgentSoftware
SMSAgentSoftware / Set-W10DefaultWallpaper.ps1
Created July 6, 2017 10:51
Used to set the default wallpaper images for Windows 10 during MDT-integrated ConfigMgr OS deployment
# Get the TS variables
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$ScriptRoot = $tsenv.Value("ScriptRoot")
$OSDTargetSystemRoot = $tsenv.Value("OSDTargetSystemRoot")
# Rename default wallpaper
Rename-Item $OSDTargetSystemRoot\Web\Wallpaper\Windows\img0.jpg img1.jpg -Force
# Copy new default wallpaper
Copy-Item $ScriptRoot\img0.jpg $OSDTargetSystemRoot\Web\Wallpaper\Windows -Force
@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()]