Skip to content

Instantly share code, notes, and snippets.

@wise-io
Last active January 29, 2025 18:23
Show Gist options
  • Save wise-io/94aab9d0936908cd0e933a08351e818c to your computer and use it in GitHub Desktop.
Save wise-io/94aab9d0936908cd0e933a08351e818c to your computer and use it in GitHub Desktop.
PowerShell Script to Initiate Microsoft Office Updates
# Initiates Microsoft Office updates
$Path = 'C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeC2RClient.exe'
$Arguments = '/update user'
# Get the process name
$ProcessName = [System.IO.Path]::GetFileNameWithoutExtension($Path)
# Check if Microsoft Office updates are running
$Running = Get-Process $ProcessName -ErrorAction SilentlyContinue
# If not running, start Microsoft Office updates
if (!$Running) {
Write-Output 'Starting Microsoft Office update process...'
Start-Process -FilePath $Path -ArgumentList $Arguments
}
else {
Write-Output 'The Microsoft Office update process is currently running.'
}
@ColossusD88
Copy link

Here is it corrected without the else } cmdlet error argument it will kick back. Thank you so much by the way Wise-io!

Initiates Microsoft Office updates

$Path = 'C:\Program Files\Common Files\Microsoft Shared\ClickToRun\OfficeC2RClient.exe'
$Arguments = '/update user'

Get the process name

$ProcessName = [System.IO.Path]::GetFileNameWithoutExtension($Path)

Check if Microsoft Office updates are running

$Running = Get-Process $ProcessName -ErrorAction SilentlyContinue

If not running, start Microsoft Office updates

if (!$Running) {
Write-Output 'Starting Microsoft Office update process...'
Start-Process -FilePath $Path -ArgumentList $Arguments
} else {
Write-Output 'The Microsoft Office update process is currently running.'
}

@wise-io
Copy link
Author

wise-io commented Jan 29, 2025

Thanks for the kind words @ColossusD88! Be sure to check out the maintained version of this script here, and my documentation site at https://scripts.aaronjstevenson.com/ for other useful scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment