Skip to content

Instantly share code, notes, and snippets.

View SMSAgentSoftware's full-sized avatar

Trevor Jones SMSAgentSoftware

View GitHub Profile
@SMSAgentSoftware
SMSAgentSoftware / Get-CurrentPatchInfo.ps1
Last active February 23, 2024 20:58
Gets the current software update level of a Windows 10/11 workstation and compares with the latest available updates. Can also list all available updates for the current build.
[CmdletBinding()]
Param(
[switch]$ListAllAvailable,
[switch]$ExcludePreview,
[switch]$ExcludeOutofBand
)
$ProgressPreference = 'SilentlyContinue'
Function Get-MyWindowsVersion {
[CmdletBinding()]
@SMSAgentSoftware
SMSAgentSoftware / New-CMOverlappingBoundariesReport.ps1
Created September 3, 2021 11:12
Send an html email report containing a list of overlapping IP range boundaries in MEMCM
# MEMCM database params
$script:dataSource = 'myMEMCMSQLserver' # MEMCM SQL server name, include instance if needed
$script:database = 'CM_ABC' # MEMCM database name
# Html CSS style
$Style = @"
<style>
table {
border-collapse: collapse;
font-family: sans-serif
@SMSAgentSoftware
SMSAgentSoftware / Update-CMConfigurationItemSupportedPlatforms.ps1
Created November 29, 2021 16:18
Updates MEMCM configuration items with W10 supported platform rules to include the equivalent W11 rule
## Updates MEMCM configuration items with W10 supported platform rules to include the equivalent W11 rule
# Import ConfigMgr Module
Import-Module $env:SMS_ADMIN_UI_PATH.Replace('i386','ConfigurationManager.psd1')
$SiteCode = (Get-PSDrive -PSProvider CMSITE).Name
Set-Location ("$SiteCode" + ":")
$CMPSSuppressFastNotUsedCheck = $true
# Define the Windows 10 platform rules to check for
$W10RuleIds = @(
@SMSAgentSoftware
SMSAgentSoftware / Get-WUErrorCode.ps1
Last active February 8, 2023 17:03
Pulls Windows Update error codes from the Microsoft Docs reference pages
Function Get-WUErrorCode {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,ParameterSetName='Parameter Set 1',ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)]
[string[]]
$ErrorCode,
[Parameter(Mandatory=$true,ParameterSetName='Parameter Set 2',Position=1)]
[switch]
@SMSAgentSoftware
SMSAgentSoftware / Get-HPBIOSSettings.ps1
Created May 9, 2022 14:47
Pulls some of the BIOS settings for an HP workstation
$SetupPasswordIsSet = Get-CimInstance -Namespace ROOT\HP\InstrumentedBIOS -ClassName HP_BIOSPassword -Filter "Name='Setup Password'" -ErrorAction SilentlyContinue | Select -ExpandProperty IsSet
$PowerOnPasswordIsSet = Get-CimInstance -Namespace ROOT\HP\InstrumentedBIOS -ClassName HP_BIOSPassword -Filter "Name='Power-On Password'" -ErrorAction SilentlyContinue | Select -ExpandProperty IsSet
$SecureBoot = Get-CimInstance -Namespace ROOT\HP\InstrumentedBIOS -ClassName HP_BIOSEnumeration -Filter "Name='Secure Boot'" -ErrorAction SilentlyContinue | Select -ExpandProperty CurrentValue
$LANWLANAutoSwitching = Get-CimInstance -Namespace ROOT\HP\InstrumentedBIOS -ClassName HP_BIOSEnumeration -Filter "Name='LAN / WLAN Auto Switching'" -ErrorAction SilentlyContinue | Select -ExpandProperty CurrentValue
$ThunderboltSecurityLevel = Get-CimInstance -Namespace ROOT\HP\InstrumentedBIOS -ClassName HP_BIOSEnumeration -Filter "Name='Thunderbolt Security Level'" -ErrorAction SilentlyContinue | Select -ExpandProperty CurrentValue
@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 / Convert-CCMLogToObjectArray.ps1
Created June 22, 2022 14:18
PowerShell function to convert a log formatted with the ConfigMgr log schema into an array of objects
## PowerShell function to convert a log formatted with the ConfigMgr log schema into an array of objects
# Parameters:
# - LogPath. The full path to the log file
# - LineCount. The number of log entries to return, starting from the BOTTOM up (ie most recent back). Default: 500.
function Convert-CCMLogToObjectArray {
Param ($LogPath,$LineCount = 500)
# Custom class to define a log entry
class LogEntry {
@SMSAgentSoftware
SMSAgentSoftware / Get-ManagedDeviceGroupMembership.ps1
Last active November 10, 2022 14:53
Gets the transitive AAD group membership of an Intune managed device
## Requires the Microsoft.Graph.Intune module
## Examples:
$GroupMembership = Get-DeviceGroupMembership -DeviceName "PC001"
$GroupMembership = Get-DeviceGroupMembership -AADDeviceId "c089201c-ad84-1234-5678-00d06dc86d8f"
$GroupMembership | Sort Name | Out-GridView
# Is device a member of a specific group
$GroupMembership.Name -contains "Intune - All Windows 10 Workstations"
@SMSAgentSoftware
SMSAgentSoftware / Set-HPBIOSPassword
Created September 12, 2022 16:42
Sets the initial password for HP BIOS
##########################
## SET HP BIOS PASSWORD ##
##########################
#region SetBIOSPassword
Write-Output "Setting BIOS password"
# Check if HP BIOS Password is set
Try
{
$HPBIOSClassExists = Get-CimClass -Namespace ROOT\HP\InstrumentedBIOS -ClassName HP_BIOSSettingInterface -ErrorAction Stop
}
@SMSAgentSoftware
SMSAgentSoftware / PSEncryptDecrypt.ps1
Last active February 28, 2024 13:36
PowerShell examples for symmetric and asymmetric encryption with the .Net cryptography model
# Example code for encrypting and decrypting secrets with .Net cryptography using either symmetric or asymmetric encryption
###################################
## SYMMETRIC ENCRYPTION ##
## Using AES 256-bit in CBC mode ##
###################################
# Create an AES key and Initialization vector
$AES = [System.Security.Cryptography.Aes]::Create()
$Key = [System.Convert]::ToBase64String($aes.Key)