Skip to content

Instantly share code, notes, and snippets.

View contactbrenton's full-sized avatar
Found on Linkedin "Brenton Johnson"

Brenton Johnson contactbrenton

Found on Linkedin "Brenton Johnson"
  • Uptake Digital
  • Australia
View GitHub Profile
@contactbrenton
contactbrenton / Check-Updates-WUA.ps1
Last active April 14, 2024 07:58
Check Windows updates using Windows Update Agent (WUA)
<#
.DESCRIPTION
The script uses a COM object to interact with the Windows Update service, searching for any updates that are currently available but not installed. If no updates are pending, it confirms the system is up to date. Otherwise, it lists all pending updates by title.
#>
# Create a COM object for Windows Update Session
$UpdateSession = New-Object -ComObject "Microsoft.Update.Session"
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
# Search for pending updates
@contactbrenton
contactbrenton / Update-Office-C2R.ps1
Created February 14, 2024 04:57
Updates Office Click to Run
# Check for Office Click-To-Run Products
$officeC2R = Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*,HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*Microsoft Office Professional Plus 2019*" -or $_.DisplayName -like "*Microsoft Office Professional Plus 2021*" -or $_.DisplayName -like "*Microsoft Office 365*" -or $_.DisplayName -like "*Microsoft 365*"}
# Update Click-To-Run Office Products (Office 2019, 2021, 365, etc)
if ($officeC2R -ne $null) {
if (Test-Path "C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe") {
Write-Output "Click-To-Run Office detected. Initiating update."
& "C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe" /update user displaylevel=false forceappshutdown=true
}
else {
@contactbrenton
contactbrenton / remove-powershell-get-1.0.0.1.ps1
Created February 4, 2024 23:09
Remove the old version of Powershell Get
$folders = @(
"C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1",
"C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1",
"C:\Program Files (x86)\WindowsPowerShell\Modules\PackageManagement\1.0.0.1",
"C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1"
)
foreach ($folder in $folders) {
if (Test-Path $folder) {
Write-Host "Deleting folder: $folder"
@contactbrenton
contactbrenton / Install-HPCMSL.ps1
Last active February 4, 2024 23:09
Install-HPCMSL.ps1
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Start-Sleep -Seconds 60
Install-Module -Name PowerShellGet -Force
Install-Module -Name HPCMSL -SkipPublisherCheck -AcceptLicense -Force
Import-Module -Name HPCMSL
Write-Host "HP Client Management Script Library installation complete."
<#Detection on CI:
#Requires HPCMSL already Installed.
$HPCMSLVers = Get-InstalledModule -Name "HPCMSL" -ErrorAction SilentlyContinue
if ((Get-CimInstance -Namespace root/cimv2 -ClassName Win32_ComputerSystem).Manufacturer -like "H*"){$IsHP = $true}
if ($HPCMSLVers -ne $Null -and $IsHP -eq $true)
{
Write-Output "HP with HPCMSL"
}
#>
# Define the paths for both x64 and x86 versions of the Dell Command Update CLI
$dcuPathX64 = "${env:ProgramFiles}\Dell\CommandUpdate\dcu-cli.exe"
$dcuPathX86 = "${env:ProgramFilesX86}\Dell\CommandUpdate\dcu-cli.exe"
# Check if Dell Command Update is installed (either x64 or x86)
$dcuPath = if (Test-Path $dcuPathX64) {
$dcuPathX64
} elseif (Test-Path $dcuPathX86) {
$dcuPathX86
} else {
<#
.SYNOPSIS
This script configures the PowerShell environment for removing Visual C++ Redistributables.
It installs the NuGet package provider and the VcRedist module, and then removes specific versions of Visual C++ Redistributables.
.DESCRIPTION
The script sets the execution policy to Bypass for the current process, installs NuGet and VcRedist modules, and uninstalls specific versions of Visual C++ Redistributables (2005, 2008, 2010, 2012). It ends by listing all installed Visual C++ Redistributables.
.NOTES
Requires administrative permissions
@contactbrenton
contactbrenton / Monitor-Serials.ps1
Last active November 20, 2023 03:13
This script gathers information about connected monitors and allows the user to assign asset tags.
<#
.DESCRIPTION
This script gathers information about connected monitors and allows the user to assign asset tags. This can be used with a USB or network drive.
The script retrieves details of each monitor connected to the system, such as the manufacturer, name, serial number, week of manufacture, and year of manufacture. It prompts the user to input an asset tag number for each monitor. The collected data, including the asset tags, are then appended to a CSV file.
.PARAMETERS
The script uses hardcoded CSV file path which can be adjusted as needed.
.EXAMPLE
.\Monitor-Serials.ps1
<#
.Description
Clears Teams Cache.
.Source
https://commsverse.blog/2018/09/28/clear-the-microsoft-teams-client-cache/
#>
$challenge = Read-Host "Are you sure you want to delete Teams Cache (Y/N)?"
$challenge = $challenge.ToUpper()
@contactbrenton
contactbrenton / get-hardwarehash-to-folder.ps1
Last active September 12, 2020 10:21
Used to copy device hardware hash to a folder on the harddisk.
md c:\HWID
Set-Location c:\HWID
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
Install-Script -Name Get-WindowsAutopilotInfo -Force
$env:Path += ";C:\Program Files\WindowsPowerShell\Scripts"
Get-WindowsAutopilotInfo.ps1 -OutputFile AutopilotHWID.csv