Skip to content

Instantly share code, notes, and snippets.

View SMSAgentSoftware's full-sized avatar

Trevor Jones SMSAgentSoftware

View GitHub Profile
@SMSAgentSoftware
SMSAgentSoftware / Get-IntuneTenantId.ps1
Created December 18, 2023 18:35
Retrieve your Intune tenant/account Id from a locally installed Intune certificate
using namespace System.Security.Cryptography.X509Certificates
function Get-IntuneTenantId {
# Check if "using namespace System.Security.Cryptography.X509Certificates" has been run
try
{
$x509Store = [X509Store]::new([StoreName]::My,[StoreLocation]::LocalMachine)
}
# If not, add the required type accelerators
catch
{
@SMSAgentSoftware
SMSAgentSoftware / New-MgMailMessage.ps1
Last active November 22, 2023 20:27
Wrapper function to simplify generating a mail message for Send-MgUserMail with Microsoft Graph
#Requires -Modules Microsoft.Graph.Authentication, Microsoft.Graph.Users.Actions
function New-MgMailMessage {
param (
[Parameter(Mandatory=$true)]
[string]$Subject,
[Parameter(Mandatory=$true)]
[string]$Body,
[Parameter(Mandatory=$false)]
[ValidateSet("Text", "Html")]
[string]$BodyType = "Text",
@SMSAgentSoftware
SMSAgentSoftware / Invoke-MgDeviceRemediationOnDemand.ps1
Last active July 13, 2023 21:06
Invokes an Intune remediation script on demand against one or more devices (Microsoft.Graph.PowerShell version)
function Invoke-MgDeviceRemediationOnDemand {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string[]]
$Computername
)
@SMSAgentSoftware
SMSAgentSoftware / Get-MgDeviceRemediationsStatus.ps1
Last active July 13, 2023 21:04
Retrieves the Intune Remediation script statuses for one or more managed devices (Microsoft.Graph.PowerShell version)
Function Get-MgDeviceRemediationsStatus {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string[]]
$Computername
)
@SMSAgentSoftware
SMSAgentSoftware / Get-IntuneDeviceRemediationsStatus.ps1
Last active July 13, 2023 20:58
Retrieves the Intune remediation scripts statuses for one or more managed devices
Function Get-IntuneDeviceRemediationsStatus {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string[]]
$Computername
)
@SMSAgentSoftware
SMSAgentSoftware / Invoke-IntuneRemediationOnDemand.ps1
Last active July 13, 2023 20:56
Invokes an Intune remediations script on demand against one or more devices
function Invoke-IntuneRemediationOnDemand {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string[]]
$Computername
)
@SMSAgentSoftware
SMSAgentSoftware / Get-WindowsUpdateInstalledDriverDetails.ps1
Created July 7, 2023 14:37
Translates locally installed Windows update drivers to actual drivers
class Driver {
[string]$WUName
[datetime]$InstallDate
[string]$DeviceName
[string]$FriendlyName
[datetime]$DriverDate
[string]$DriverVersion
[string]$Manufacturer
}
$DriverList = [System.Collections.Generic.List[Driver]]::new()
@SMSAgentSoftware
SMSAgentSoftware / Get-WindowsUpdateHistory.ps1
Last active May 31, 2023 10:09
PowerShell 'one-liner' to get Windows Update history using the PackageManagement module
Get-Package -ProviderName msu |
Select Name,
@{l='UpdateType';e={
If ($_.Name -match "Antivirus" -or $_.Name -match "antimalware")
{"Definition Update"}
ElseIf ($_.Metadata.Item("SupportUrl") -match "target=hub")
{"Driver Update"}
ElseIf ($_.Summary -match "latest version of Windows")
{"Feature Update"}
ElseIf ($_.Name -match "Malicious Software Removal" -or $_.Name -match "Intelligence Update")
@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)
@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
}