Run-GPUpdateSilently.ps1

  • 1 August 2022
  • Sean Huggans
Description: 

Script is meant for use as a ConfigMgr console script. It will run GPUpdate silently, without any popups, etc. on logged in user's screens.

Language: 
PowerShell
Usage Type: 
ConfigMgr Console
Script Source: 
################################################################################################################################
# GPUpdate Script
# Script Auther: Sean Huggans
# Script Version 18.06.05
################################################################################################################################
# Variables
################
$LogDir = "C:\Temp\System Compliance"
$LogName = "GPUpdate"
$LogPath = "$($LogDir)\$($LogName).log"
 
###################
# Functions
###################
function Log-Action ($Message) {
    if (!(test-path -Path $LogDir)) {
        New-Item -ItemType Directory -Path $LogDir -Confirm:$false -Force | Out-Null
    }
    "[ $(Get-Date -Format 'yyyy.MM.dd HH:mm:ss') ] $($Message)" | Out-File -FilePath $LogPath -Force -Append
}
 
try {
    $JobName = "GPUpdate$PC-$(Get-Date -format "yyyyMMddHHmmss")"
    Start-Job -Name $JobName -ScriptBlock { & echo n | GPUpdate /Force /wait:0 } | Out-Null
    $count = 60
 
    do {
        switch ($(Get-Job -Name $JobName).State) {
            "Running" {
                Start-Sleep -Seconds 1
            }
            "Completed" {
                Log-Action "GPUpdate Invoked."
                Remove-job -Name $JobName -Confirm:$false -Force -erroraction SilentlyContinue
                return "Success"
            }
            "Failed" {
                Remove-job -Name $JobName -Confirm:$false -Force -erroraction SilentlyContinue
                return "Failed (GPUpdate Failed)"
            }
        }
        $count -=1
    } until ($count -le 0)
    Remove-job -Name $JobName -Confirm:$false -Force -erroraction SilentlyContinue
    return "Failed (Time Exceeded 60 Seconds)"
} catch {
    Log-Action "Invoking GPUpdate Failed."
    return "Failure (Starting Job)"
}
Note: that all applications posted here are posted for use, both commercial and non-commercial, free of charge, and as such are provided as-is, without warranty of any kind whatsoever. visuaFUSION, FMSCUG or any other program listed here's author are not responsible for any damages or shortcomings that result from usage of any of these applications.
Error | visuaFUSION Systems Solutions Blog

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /mnt/home/visuafus/public_html/bahusa.net/includes/common.inc:2861) in drupal_send_headers() (line 1551 of /mnt/home/visuafus/public_html/bahusa.net/includes/bootstrap.inc).
  • Error: Call to undefined function mail() in DefaultMailSystem->mail() (line 79 of /mnt/home/visuafus/public_html/bahusa.net/modules/system/system.mail.inc).

Error

The website encountered an unexpected error. Please try again later.