Trying to keep desktop computers running reliably and fast requires maintenance beyond patching. In this blog, I will discuss some of my favorite maintenance tasks that can be performed with Edge DX.
This blog is just one in a four-part series called Improving the Digital Employee Experience:
Try Edge DX free with the 50-User VIP Pack.
As discussed in previous blogs, we use Edge DX scripts to help troubleshoot and remediate Windows, macOS, and Linux. This blog will discuss how scripts can be essential for maintaining desktop computers for years to maintain performance and reliability.
Scripts can be set to run automatically in many different ways. For maintenance-type tasks, you can select a trigger to run a script, such as Short Intervals (120 seconds), Long Intervals (600 seconds), Once Per Day, Process or Application Start, Logon, etc. In Figure 1, you can see some of the option configurations to trigger a script.
Since scripts can do almost any maintenance task on a desktop computer, we also know that scripts can be started based on time, boot-up, etc. So, here are some of my favorite maintenance actions.
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Name "01" -Value 1 Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Name "2048" -Value 30
<# .SYNOPSIS Gets the CPU temperature .DESCRIPTION Gets the CPU temperature from WMI Class MsAcpi_ThermalZoneTemperature .NOTES Not all motherboard BIOS software implements Acpi_ThermalZoneTemperature. If the call fails this does not necessarily indicate there is something wrong with the motherboard, it has simply not been implemented. 28-02-2022: Ton de Vreede - Added minimum PS version - Added error handling #> $ErrorActionPreference = 'Stop' # Set output encoding to ensure non-ASCII characters are captured [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # Try get temperature from MsAcpi_ThermalZoneTemperature class try { [string]$output = Get-WmiObject -Namespace root/wmi -ClassName MsAcpi_ThermalZoneTemperature -Filter "Active='True' and CurrentTemperature<>2732" -Property InstanceName, CurrentTemperature | Select-Object InstanceName, @{n = 'CurrentTemperatureC'; e = { '{0:n0} C' -f (($_.CurrentTemperature - 2732) / 10.0) } } | ConvertTo-Json Write-Output("### SIP DATA BEGINS ###") Write-Output $output Write-Output("### SIP DATA ENDS ###") } catch { Write-Output("### SIP EVENT BEGINS ###") Write-Output -InputObject 'The temperature could not be retrieved. The motherboard BIOS software has probably not implemented this MsAcpi_ThermalZoneTemperature.' Write-Output("### SIP EVENT ENDS ###") }
# Get the path to the temporary internet files folder $ieCachePath = [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Windows', 'INetCache') # Remove files in the temporary internet files folder Remove-Item -Path "$ieCachePath\*" -Force -Recurse Write-Host "Temporary internet files deleted successfully."
Optimize-Volume -DriveLetter C -ReTrim -Analyze
# Reset default file associations using dism # Define common file types $fileTypes = ".txt", ".jpg", ".png", ".pdf" # Add more file types as needed foreach ($fileType in $fileTypes) { $command = "Dism.exe /Online /Import-DefaultAppAssociations:C:\Path\To\DefaultAppAssociations.xml" Invoke-Expression -Command $command } Write-Host "File associations reset to default."
# Run SFC scan function Run-SfcScan { try { # Start SFC process Start-Process -FilePath "sfc.exe" -ArgumentList "/scannow" -Wait -NoNewWindow Write-Host "SFC scan completed successfully." return $true } catch { Write-Host "Error running SFC scan: $_" return $false } } # Example usage Run-SfcScan
# Check registry integrity function Test-RegistryIntegrity { param ( [string]$registryHive = "HKLM:\System\CurrentControlSet\Control" ) try { # Try to access the specified registry key Get-Item -LiteralPath $registryHive | Out-Null Write-Host "Registry integrity check passed. The specified registry key exists and is accessible." return $true } catch { Write-Host "Registry integrity check failed. Unable to access the specified registry key." return $false } } # Example usage Test-RegistryIntegrity
# Get a list of startup applications using WMI $StartupApps = Get-CimInstance -Namespace "Root\CIMv2" -Class Win32_StartupCommand # List the startup applications Write-Host "Startup Applications:" Write-Output("### SIP EVENT BEGINS ###") foreach ($app in $StartupApps) { Write-Host "Name: $($app.Name)" Write-Host "Command: $($app.Command)" Write-Host "Location: $($app.Location)" Write-Host "User: $($app.User)" Write-Host "" Write-Host "------------------" } # Set output encoding to ensure non-ASCII characters are captured [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # Write output Write-Output $arrPrinters Write-Output("### SIP EVENT ENDS ###") Exit 0 catch { Write-Output("### SIP EVENT BEGINS ###") Write-Output -InputObject "There was a problem retrieving the printer details for the user:`n$_" Write-Output("### SIP EVENT ENDS ###") Exit 1 }
Maintenance scripts are easy to implement and powerful to use, and as always, make sure you thoroughly test the scripts before putting them into production.
Improving the Digital Employee Experience blog series: