Skip to content

Instantly share code, notes, and snippets.

View SMSAgentSoftware's full-sized avatar

Trevor Jones SMSAgentSoftware

View GitHub Profile
@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 / 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 / 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-DeliveryOptimizationDownloadHistory.ps1
Created June 20, 2022 16:58
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" }
# Custom classes to contain put the parsed data into
class bytes {
[int]$File
[int]$CDN
[int]$DOINC
[int]$rledbat
@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-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 / 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 / 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 / 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 / Invoke-HPBIOSUpdate.ps1
Last active January 23, 2024 06:01
Silently updates an HP BIOS using HP Image Assistant
#####################
## HP BIOS UPDATER ##
#####################
# Params
$HPIAWebUrl = "https://ftp.hp.com/pub/caps-softpaq/cmit/HPIA.html" # Static web page of the HP Image Assistant
$BIOSPassword = "MyPassword"
$script:ContainerURL = "https://mystorageaccount.blob.core.windows.net/mycontainer" # URL of your Azure blob storage container
$script:FolderPath = "HP_BIOS_Updates" # the subfolder to put logs into in the storage container
$script:SASToken = "mysastoken" # the SAS token string for the container (with write permission)