From bbb48848182e6475ec624292a1b37c403eb9d200 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Thu, 5 Oct 2023 13:11:38 -0400 Subject: [PATCH] major update to override Write-Output func --- Cleanup-SystemPath.ps1 | 2 +- Cleanup-SystemTempFiles.ps1 | 58 ++--- Disable-TabletMode.ps1 | 4 +- Fix-AteraAgent.ps1 | 10 +- Fix-AutodeskProductLicensing.ps1 | 6 +- Fix-ClearOutlookAutoCompleteCache.ps1 | 2 +- Fix-ClearQuickAccess.ps1 | 8 +- Fix-DellOptimizer.ps1 | 6 +- Fix-EmberkomCloudBackupProductEdition.ps1 | 4 +- Fix-EnableGPUScheduling.ps1 | 16 +- Fix-EnableSystemRestore.ps1 | 4 +- Fix-MicrosoftTeams.ps1 | 10 +- Fix-OfficeModernAuth.ps1 | 4 +- Fix-SystemPrintQueue.ps1 | 2 +- Fix-WindowsHealth.ps1 | 33 ++- Fix-WindowsScriptingComponents.ps1 | 6 +- Fix-WindowsUpdate.ps1 | 8 +- Get-EventData.ps1 | 14 +- Get-InstalledSoftware.ps1 | 2 +- Install-4KVideoDownloader.ps1 | 6 +- Install-AdobeConnect.ps1 | 4 +- Install-AteraAgent.ps1 | 24 +-- Install-DeltekVision.ps1 | 8 +- Install-DisplayLink.ps1 | 2 +- Install-ESETManagementAgent.ps1 | 12 +- Install-EmberkomCloudBackup.ps1 | 6 +- Install-Enscape.ps1 | 4 +- Install-LiquidFilesOutlookAgent.ps1 | 10 +- Install-ManagementAgent.ps1 | 2 +- Install-Nextcloud.ps1 | 2 +- Install-OpenVPN.ps1 | 4 +- Install-SimpleInOut.ps1 | 6 +- Install-SpecsIntact.ps1 | 4 +- Install-SyncroAgent.ps1 | 4 +- Install-VLC.ps1 | 2 +- Install-Wireguard.ps1 | 2 +- Install-ZeroTier.ps1 | 16 +- Remove-DeltekVision.ps1 | 4 +- Remove-OldFiles.ps1 | 8 +- Remove-OldRevitLocals.ps1 | 2 +- Start-Windows10UpdateAssistant.ps1 | 22 +- Test-InternetBandwidth.ps1 | 20 +- Tools.ps1 | 248 +++++++++++----------- Uninstall-AdobeFlash.ps1 | 8 +- Uninstall-AteraAgent.ps1 | 48 ++--- Uninstall-AutodeskDesktopApp.ps1 | 22 +- Uninstall-EmberkomCloudBackup.ps1 | 2 +- Uninstall-MicrosoftOffice.ps1 | 4 +- Uninstall-NCentralComponents.ps1 | 30 +-- Uninstall-UnwantedDefaultApps.ps1 | 8 +- Update-Wireguard.ps1 | 6 +- Upload-Data.ps1 | 6 +- 52 files changed, 377 insertions(+), 378 deletions(-) diff --git a/Cleanup-SystemPath.ps1 b/Cleanup-SystemPath.ps1 index d8565f1..626890f 100644 --- a/Cleanup-SystemPath.ps1 +++ b/Cleanup-SystemPath.ps1 @@ -19,7 +19,7 @@ Foreach ( $path in $CURRENT_PATH.Split(";") ) } } -LogMsg "Removed Paths:`n`r${REMOVE_PATH}" +Write-Output "Removed Paths:`n`r${REMOVE_PATH}" Try { Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $NEW_PATH } Catch diff --git a/Cleanup-SystemTempFiles.ps1 b/Cleanup-SystemTempFiles.ps1 index 9adecfa..ee1de98 100644 --- a/Cleanup-SystemTempFiles.ps1 +++ b/Cleanup-SystemTempFiles.ps1 @@ -7,14 +7,14 @@ $TimeDelta = New-TimeSpan -Days $OlderThan # Remove all *.evtx files from system temporary files location $EventLogs = Get-ChildItem -Path "${Env:SystemRoot}\TEMP\*" -File -Filter *.evtx If ( $EventLogs ) { - LogMsg "Deleting all event logs from ${Env:SystemRoot}\TEMP" + Write-Output "Deleting all event logs from ${Env:SystemRoot}\TEMP" ForEach ( $EventLog in $EventLogs ) { Remove-Item $EventLog -Force -ErrorAction SilentlyContinue } } # Remove misc logs and error reports $MiscLogs = Get-ChildItem -Path "${Env:SystemRoot}\TEMP\*" -File -Include "${Env:COMPUTERNAME}-*.log", "AppxErrorReport_*.txt" If ( $MiscLogs ) { - LogMsg "Deleting misc logs from ${Env:SystemRoot}\TEMP" + Write-Output "Deleting misc logs from ${Env:SystemRoot}\TEMP" ForEach ( $MiscLog in $MiscLogs ) { Remove-Item $MiscLog -Force -ErrorAction SilentlyContinue } } @@ -25,20 +25,20 @@ If ( $CBSLogs ) { ForEach ( $CBSLog in $CBSLogs) { $TotalBytes += $CBSLog.Length } $TotalSize = [math]::Round(($TotalBytes / 1MB),2) If ( $TotalSize -ge 200 ) { - LogMsg "Total CBS log archive size: ${TotalSize}MB" + Write-Output "Total CBS log archive size: ${TotalSize}MB" Control-Service -Stop 'TrustedInstaller' - LogMsg "Deleting primary CBS.log file" + Write-Output "Deleting primary CBS.log file" Remove-Item "${Env:SystemRoot}\Logs\CBS\CBS.log" -Force -ErrorAction SilentlyContinue Control-Service -Start 'TrustedInstaller' } - LogMsg "Deleting archived CBS logs from ${Env:SystemRoot}\Logs\CBS" + Write-Output "Deleting archived CBS logs from ${Env:SystemRoot}\Logs\CBS" ForEach ( $CBSLog in $CBSLogs ) { Remove-Item $CBSLog -Force -ErrorAction SilentlyContinue } } # Remove all system temp files older than 7 days $OldTempFiles = Get-ChildItem -Path "${Env:SystemRoot}\TEMP" | Where { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) } If ( $OldTempFiles ) { - LogMsg "Deleting all temp files not modified in ${OlderThan} day(s) from ${Env:SystemRoot}\TEMP" + Write-Output "Deleting all temp files not modified in ${OlderThan} day(s) from ${Env:SystemRoot}\TEMP" ForEach ( $OldTempFile in $OldTempFiles ) { Remove-Item $OldTempFile -Force -Recurse -ErrorAction SilentlyContinue } } @@ -62,7 +62,7 @@ ForEach($file in $RecycleBin.Items()) { # Turn off system hibernation if it's in use If ( Test-Path "${Env:SystemDrive}\hiberfil.sys" ) { - LogMsg "Turning off system hibernation" + Write-Output "Turning off system hibernation" Try { Start-Process "powercfg" -ArgumentList "-h off" -Wait } Catch { LogErr $_.Exception.Message } } @@ -70,7 +70,7 @@ If ( Test-Path "${Env:SystemDrive}\hiberfil.sys" ) { # Remove PDCRevocation dump files $PDCRevocationDumpFiles = Get-ChildItem -Path "${Env:SystemRoot}\LiveKernelReports\*" -File -Include "PDCRevocation-*.dmp" If ( $PDCRevocationDumpFiles ) { - LogMsg "Deleting PDCRevocation dump files from ${Env:SystemRoot}\LiveKernelReports" + Write-Output "Deleting PDCRevocation dump files from ${Env:SystemRoot}\LiveKernelReports" ForEach ( $PDCRevocationDump in $PDCRevocationDumpFiles ) { Remove-Item $PDCRevocationDump -Force -ErrorAction SilentlyContinue } } @@ -79,7 +79,7 @@ If ( Test-Path "${Env:ProgramData}\Genetec\Dumps" ) { $GenetecCrashDumps = Get-ChildItem -Path "${Env:ProgramData}\Genetec\Dumps" If ( $GenetecCrashDumps ) { - LogMsg "Deleting Genetec application crash dumps" + Write-Output "Deleting Genetec application crash dumps" Try { ForEach ( $dump in $GenetecCrashDumps ) { Remove-Item $dump.FullName -Force -Recurse -ErrorAction SilentlyContinue } } Catch { LogErr $_.Exception.Message } } @@ -89,16 +89,16 @@ If ( Test-Path "${Env:ProgramData}\Genetec\Dumps" ) { $ESDB = "${Env:ProgramData}\Microsoft\Search\Data\Applications\Windows\Windows.edb" If ( Test-Path $ESDB ) { Try { - LogMsg "Found Windows Elastic Search database: ""${ESDB}""" - LogMsg " - Disabling Windows Search service" + Write-Output "Found Windows Elastic Search database: ""${ESDB}""" + Write-Output " - Disabling Windows Search service" Start-Process "sc.exe" -ArgumentList "config wsearch start= disabled" -Wait - LogMsg " - Stopping Windows Search Service" + Write-Output " - Stopping Windows Search Service" Start-Process "net.exe" -ArgumentList "stop wsearch" -Wait - LogMsg " - Defragmenting database file" + Write-Output " - Defragmenting database file" Start-Process "esentutl.exe" -ArgumentList "/d ""${ESDB}""" -Wait - LogMsg " - Enabling Windows Search Service" + Write-Output " - Enabling Windows Search Service" Start-Process "sc.exe" -ArgumentList "config wsearch start= delayed-auto" -Wait - LogMsg " - Starting Windows Search Service" + Write-Output " - Starting Windows Search Service" Start-Process "net.exe" -ArgumentList "start wsearch" -Wait } Catch { LogErr $_.Exception.Message } @@ -111,7 +111,7 @@ If ( Test-Path $ADSKInst ) { $foldersToDelete = Get-ChildItem -Path $ADKSInst -ErrorAction SilentlyContinue | Where-Object { ($_.PSIsContainer) -and ($_.LastWriteTime -lt ((Get-Date) - $TimeDelta)) -and ( $_.Name -ne "WI") } ForEach ( $folder in $foldersToDelete ) { $path = $folder.FullName - LogMsg "Deleting Autodesk installer directory: ""${path}""" + Write-Output "Deleting Autodesk installer directory: ""${path}""" Try { Remove-Item $folder -Force -Recurse -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } @@ -125,7 +125,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # Remove all user temp files older than 7 days $OldTempFiles = Get-ChildItem -Path "${userProfile}\AppData\Local\Temp" -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) } If ( $OldTempFiles ) { - LogMsg "Deleting all temp files not modified in ${OlderThan} day(s) from ""${userProfile}\AppData\Local\Temp""" + Write-Output "Deleting all temp files not modified in ${OlderThan} day(s) from ""${userProfile}\AppData\Local\Temp""" ForEach ( $OldTempFile in $OldTempFiles ) { Remove-Item $OldTempFile -Force -Recurse -ErrorAction SilentlyContinue } } @@ -133,7 +133,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { If (-not (IsRunning -Name "acad") ) { $AutoCADTempFiles = Get-ChildItem -Path "${userProfile}\AppData\Local\Temp\*" -File -Include '*.ac$' -ErrorAction SilentlyContinue If ( $AutoCADTempFiles ) { - LogMsg "Deleting AutoCAD temp files" + Write-Output "Deleting AutoCAD temp files" ForEach ( $tempfile in $AutoCADTempFiles ) { Try { Remove-Item $tempfile -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } @@ -167,18 +167,18 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # } # If ( $IPSW ) { - # LogMsg "Found Apple software update files" + # Write-Output "Found Apple software update files" # ForEach ( $path in $IPSW ) { - # LogMsg " - Deleting: ""${path}""" + # Write-Output " - Deleting: ""${path}""" # Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } # Catch { LogErr $_.Exception.Message } # } # } # If ( $IPA ) { - # LogMsg "Found Apple mobile application files" + # Write-Output "Found Apple mobile application files" # ForEach ( $path in $IPA ) { - # LogMsg " - Deleting: ""${path}""" + # Write-Output " - Deleting: ""${path}""" # Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } # Catch { LogErr $_.Exception.Message } # } @@ -188,10 +188,10 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # Remove old downloaded application files $OldDownloadedApps = (Get-ChildItem -Path "${userProfile}\Downloads\*" -File -Filter '*.exe' -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) }) If ( $OldDownloadedApps ) { - LogMsg "Deleting old downloaded app files" + Write-Output "Deleting old downloaded app files" ForEach ( $oldDownloadedApp in $OldDownloadedApps ) { $path = $oldDownloadedApp.FullName - LogMsg " - Deleting: ""${path}""" + Write-Output " - Deleting: ""${path}""" Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } @@ -223,7 +223,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { If ( Test-Path $ToDelete ) { # Delete the duplicate file - LogMsg "Deleting duplicate download: ""${ToDelete}""" + Write-Output "Deleting duplicate download: ""${ToDelete}""" Try { Remove-Item -Path $ToDelete -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } @@ -235,10 +235,10 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # Remove old Outlook backup files $OldOutlookBackupFiles = Get-ChildItem -Path "${userProfile}\AppData\Local\Microsoft\Outlook\*" -File -Filter '*.bak' -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -lt ((Get-Date) - $TimeDelta) } If ( $OldOutlookBackupFiles ) { - LogMsg "Found Outlook backup files older than ${OlderThan} days:" + Write-Output "Found Outlook backup files older than ${OlderThan} days:" ForEach ( $file in $OldOutlookBackupFiles ) { $path = $file.FullName - LogMsg "Deleting: ""${path}""" + Write-Output "Deleting: ""${path}""" Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } @@ -248,8 +248,8 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # Silently run cleanmgr.exe with default settings # TODO: This does not run silently - commenting out for now! #Try { -# LogMsg "Running cleanmgr.exe with default settings for very low disk space" +# Write-Output "Running cleanmgr.exe with default settings for very low disk space" # Start-Process "cleanmgr.exe" -ArgumentList "/VERYLOWDISK" -# LogMsg " - Finished" +# Write-Output " - Finished" #} #Catch { LogErr $_.Exception.Message } \ No newline at end of file diff --git a/Disable-TabletMode.ps1 b/Disable-TabletMode.ps1 index 667c0a8..7b1c212 100644 --- a/Disable-TabletMode.ps1 +++ b/Disable-TabletMode.ps1 @@ -3,7 +3,7 @@ $RegKey = 'HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell' ## Make sure endpoint is running at least Windows 8 If ( IsWindowsVersion -ge '6.3' ) { - LogMsg "Disabling tabled mode" + Write-Output "Disabling tabled mode" Try { Set-ItemProperty $RegKey -Name 'TabletMode' -Value 0 @@ -11,4 +11,4 @@ If ( IsWindowsVersion -ge '6.3' ) } Catch { LogErr $_.Exception.Message } } -Else { LogMsg "Tablet mode is only supported on Windows 8 and higher" } \ No newline at end of file +Else { Write-Output "Tablet mode is only supported on Windows 8 and higher" } \ No newline at end of file diff --git a/Fix-AteraAgent.ps1 b/Fix-AteraAgent.ps1 index b68e930..f9e4007 100644 --- a/Fix-AteraAgent.ps1 +++ b/Fix-AteraAgent.ps1 @@ -5,21 +5,21 @@ $FolderNewName = "${FolderToRename}${RenameSuffix}" # Kill processes that can interfere 'reg', 'AgentPackageTaskManagement' | ForEach-Object { Get-Process -Name $_ -ErrorAction SilentlyContinue | Stop-Process -Force } -LogMsg "Stopping Atera agent" +Write-Output "Stopping Atera agent" Stop-Service -Name 'AteraAgent' -Force If ( Test-Path $FolderNewName ) { - LogMsg "Deleting previously renamed folder: ${FolderNewName}" + Write-Output "Deleting previously renamed folder: ${FolderNewName}" Try { Remove-Item $FolderNewName -Recurse -Force } Catch { LogErr $_.Exception.Message } } -LogMsg "Stopping AgentPackageMonitoring process" +Write-Output "Stopping AgentPackageMonitoring process" Get-Process -Name "AgentPackageMonitoring" -ErrorAction SilentlyContinue | Stop-Process -Force -LogMsg "Renaming ${FolderToRename}" +Write-Output "Renaming ${FolderToRename}" Try { Rename-Item $FolderToRename $FolderNewName -Force } Catch { LogErr $_.Exception.Message } -LogMsg "Starting Atera agent" +Write-Output "Starting Atera agent" Start-Service -Name 'AteraAgent' \ No newline at end of file diff --git a/Fix-AutodeskProductLicensing.ps1 b/Fix-AutodeskProductLicensing.ps1 index bd41f60..f806bd4 100644 --- a/Fix-AutodeskProductLicensing.ps1 +++ b/Fix-AutodeskProductLicensing.ps1 @@ -12,19 +12,19 @@ $WorkingDir = '{0}\{1}' -f (Split-Path -Path $LicensingSupportTool -Parent), "Ad $ALST = "${WorkingDir}\AdskLicensingSupportTool.exe" If ( Test-Path $ALST ) { - LogMsg "Resetting all Autodesk product licenses to named-user licenses" + Write-Output "Resetting all Autodesk product licenses to named-user licenses" Try { Start-Process $ALST -ArgumentList '-r ALL:User' -Wait } Catch { LogErr $_.Exception.Message } } If ( Test-Path $LicensingSupportTool ) { - LogMsg "Deleting ""${LicensingSupportTool}""" + Write-Output "Deleting ""${LicensingSupportTool}""" Try { Remove-Item $LicensingSupportTool -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } If ( Test-Path $WorkingDir ) { - LogMsg "Deleting ""${WorkingDir}""" + Write-Output "Deleting ""${WorkingDir}""" Try { Remove-Item $WorkingDir -Force -Recurse -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } \ No newline at end of file diff --git a/Fix-ClearOutlookAutoCompleteCache.ps1 b/Fix-ClearOutlookAutoCompleteCache.ps1 index 29a1281..dc8ab77 100644 --- a/Fix-ClearOutlookAutoCompleteCache.ps1 +++ b/Fix-ClearOutlookAutoCompleteCache.ps1 @@ -1,3 +1,3 @@ -LogMsg "Clearing Outlook auto complete cache" +Write-Output "Clearing Outlook auto complete cache" Try { Start-Process "outlook.exe" -ArgumentList "/CleanAutoCompleteCache" -ErrorAction Stop } Catch { LogErr $_.Exception.Message } \ No newline at end of file diff --git a/Fix-ClearQuickAccess.ps1 b/Fix-ClearQuickAccess.ps1 index 45820c6..e7268ac 100644 --- a/Fix-ClearQuickAccess.ps1 +++ b/Fix-ClearQuickAccess.ps1 @@ -6,16 +6,16 @@ If ( IsWindowsVersion -ge "10.0" ) { $FILEDIR = Split-Path -Path $FILE -Parent If ( Test-Path $FILE ) { - LogMsg "Clearing Quick Access links" + Write-Output "Clearing Quick Access links" Try { Remove-Item $FILE -Force } Catch { LogErr $_.Exception.Message } } ElseIf ( Test-Path $FILEDIR ) { - LogMsg "Standard Quick Access link list is not found, clearing out all automatic destinations instead" + Write-Output "Standard Quick Access link list is not found, clearing out all automatic destinations instead" Try { Get-ChildItem "${FILEDIR}\*.*" | Where-Object { -not $_.PSIsContainer } | Remove-Item -Force } Catch { LogErr $_.Exception.Message } } Else { - LogMsg "Quick Access lists cannot be found!" + Write-Output "Quick Access lists cannot be found!" } } Else { - LogMsg "Quick Access is only available on Windows 10 or greater" + Write-Output "Quick Access is only available on Windows 10 or greater" } \ No newline at end of file diff --git a/Fix-DellOptimizer.ps1 b/Fix-DellOptimizer.ps1 index 3e27b03..d52023b 100644 --- a/Fix-DellOptimizer.ps1 +++ b/Fix-DellOptimizer.ps1 @@ -2,14 +2,14 @@ If ( Test-Path "${Env:ProgramFiles}\Dell\DellOptimizer\do-cli.exe" ) { $DellOptimizerCli = "${Env:ProgramFiles}\Dell\DellOptimizer\do-cli.exe" } ElseIf ( Test-Path "${Env:ProgramFiles(x86)}\Dell\DellOptimizer\do-cli.exe" ) { $DellOptimizerCli = "${Env:ProgramFiles(x86)}\Dell\DellOptimizer\do-cli.exe" } If ( $DellOptimizerCli ) { - LogMsg "Dell Optimizer" + Write-Output "Dell Optimizer" Try { # Disable Network Settings - LogMsg "Disabling network settings" + Write-Output "Disabling network settings" Start-Process -FilePath "C:\Program Files\Dell\DellOptimizer\do-cli.exe" -ArgumentList '/configure -name=Network.State -value=false' -Wait # Disable Presence Detection - LogMsg "Disabling presence detection" + Write-Output "Disabling presence detection" Start-Process -FilePath "C:\Program Files\Dell\DellOptimizer\do-cli.exe" -ArgumentList '/configure -name=PresenceDetection.State -value=false' -Wait } Catch { Write-Error $_.Exception.Message } diff --git a/Fix-EmberkomCloudBackupProductEdition.ps1 b/Fix-EmberkomCloudBackupProductEdition.ps1 index a651de5..5258924 100644 --- a/Fix-EmberkomCloudBackupProductEdition.ps1 +++ b/Fix-EmberkomCloudBackupProductEdition.ps1 @@ -16,14 +16,14 @@ Import-Module -Name MSP360 # Add backup user to installed product #Try { # $MSP360Password = ConvertTo-SecureString -string $MSP360Password -AsPlainText -Force -# LogMsg "Adding backup user account: ${MSP360Username}" +# Write-Output "Adding backup user account: ${MSP360Username}" # Add-MBSUserAccount -User $MSP360Username -Password $MSP360Password #} #Catch { LogErr $_.Exception.Message } # Set the agent edition # Note: the product edition must be set *after* the user is added -LogMsg "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition""" +Write-Output "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition""" Try { Set-MBSAgentSetting -Edition $AgentEdition -Verbose } Catch { LogErr $_.Exception.Message } diff --git a/Fix-EnableGPUScheduling.ps1 b/Fix-EnableGPUScheduling.ps1 index c729674..571362f 100644 --- a/Fix-EnableGPUScheduling.ps1 +++ b/Fix-EnableGPUScheduling.ps1 @@ -6,18 +6,18 @@ $HardwareGPUSchedulingEnabled = $false If ( Test-RegistryProperty -Path $key -Name $name ) { $setting = (Get-ItemPropertyValue -Path $key -Name $name -ErrorAction SilentlyContinue) If ( $setting -eq 2 ) { - LogMsg "Hardware assisted GPU scheduling is already enabled" + Write-Output "Hardware assisted GPU scheduling is already enabled" $HardwareGPUSchedulingEnabled = $true } } If ( $HardwareGPUSchedulingEnabled -eq $false ) { - LogMsg "Hardware assisted GPU scheduling is disabled" + Write-Output "Hardware assisted GPU scheduling is disabled" $HardwareGPUSchedulingEnabled = $false } # Find a GPU in the system so we can enable GPU scheduling If ( $HardwareGPUSchedulingEnabled -eq $false ) { - LogMsg " - Attempting to find a discrete Nvidia or AMD GPU" + Write-Output " - Attempting to find a discrete Nvidia or AMD GPU" $GPUs = (Get-WmiObject Win32_VideoController).Name $FoundDiscreteGPU = $false ForEach ( $gpu in $GPUs ) { @@ -28,15 +28,15 @@ If ( $HardwareGPUSchedulingEnabled -eq $false ) { # If we found a discrete GPU, enable hardware assisted GPU scheduling If ( $FoundDiscreteGPU -eq $true ) { - LogMsg " - GPU found!" - LogMsg "Enabling hardware assisted GPU scheduling" + Write-Output " - GPU found!" + Write-Output "Enabling hardware assisted GPU scheduling" Try { New-ItemProperty -Path $key -Name $name -PropertyType DWord -Value 2 -Force -ErrorAction Stop - LogMsg "A restart is required before this change will take effect" + Write-Output "A restart is required before this change will take effect" } Catch { LogErr $_.Exception.Message } } Else { - LogMsg " - No GPU was found" - LogMsg "Hardware assisted GPU scheduling will not be enabled" + Write-Output " - No GPU was found" + Write-Output "Hardware assisted GPU scheduling will not be enabled" } } diff --git a/Fix-EnableSystemRestore.ps1 b/Fix-EnableSystemRestore.ps1 index 1a824db..c3429a2 100644 --- a/Fix-EnableSystemRestore.ps1 +++ b/Fix-EnableSystemRestore.ps1 @@ -1,4 +1,4 @@ -If ( $(Get-ComputerRestorePoint) -ne $null ) { LogMsg "System Restore is already enabled" ; Exit } -LogMsg "Enabling System Restore" +If ( $(Get-ComputerRestorePoint) -ne $null ) { Write-Output "System Restore is already enabled" ; Exit } +Write-Output "Enabling System Restore" Try { Enable-ComputerRestore -Drive $Env:SystemDrive } Catch { LogErr $_.Exception.Message } \ No newline at end of file diff --git a/Fix-MicrosoftTeams.ps1 b/Fix-MicrosoftTeams.ps1 index d0d05f4..bcbcc1d 100644 --- a/Fix-MicrosoftTeams.ps1 +++ b/Fix-MicrosoftTeams.ps1 @@ -5,7 +5,7 @@ If ( Test-Path "${Env:LocalAppData}\Microsoft\Teams\Update.exe" ) { $ProcessList = (Get-Process -Name 'teams' -ErrorAction SilentlyContinue) If ( $ProcessList ) { - LogMsg "Stopping Microsoft Teams" + Write-Output "Stopping Microsoft Teams" Try { $ProcessStopped = $true ; $ProcessList | Stop-Process -Force } Catch { LogErr $_.Exception.Message } } Else { $ProcessStopped = $false } @@ -13,15 +13,15 @@ If ( Test-Path "${Env:LocalAppData}\Microsoft\Teams\Update.exe" ) { # Remove all cached content $CacheDir = "${Env:AppData}\Microsoft\Teams" If ( Test-Path $CacheDir ) { - LogMsg "Removing all cached data for Microsoft Teams" + Write-Output "Removing all cached data for Microsoft Teams" Try { Remove-Item $CacheDir -Recurse -Force } Catch { LogErr $_.Exception.Message } - } Else { LogMsg "Could not clear cached data for Microsoft Teams because the directory could not be found: ${CacheDir}" } + } Else { Write-Output "Could not clear cached data for Microsoft Teams because the directory could not be found: ${CacheDir}" } # Restart Teams if we needed to close it before clearing the cache If ( $ProcessStopped ) { - LogMsg "Starting Microsoft Teams" + Write-Output "Starting Microsoft Teams" Try { Start-Process "${Env:LocalAppData}\Microsoft\Teams\Update.exe" -ArgumentList "--processStart ""Teams.exe""" } Catch { LogErr $_.Exception.Message } } -} Else { LogMsg "Cannot clear cache for Microsoft Teams because it isn't installed" } +} Else { Write-Output "Cannot clear cache for Microsoft Teams because it isn't installed" } diff --git a/Fix-OfficeModernAuth.ps1 b/Fix-OfficeModernAuth.ps1 index 8da0c9d..45f045b 100644 --- a/Fix-OfficeModernAuth.ps1 +++ b/Fix-OfficeModernAuth.ps1 @@ -1,8 +1,8 @@ $REG_PATH = 'HKCU:\SOFTWARE\Microsoft\Exchange' $REG_PROP = 'AlwaysUseMSOAuthForAutoDiscover' If ( !((Get-ItemProperty -Path $REG_PATH -Name $REG_PROP -ErrorAction SilentlyContinue).$REG_PROP) ) { - LogMsg "Adding registry entry: ""${REG_PATH}\${REG_PROP}"" = 1" + Write-Output "Adding registry entry: ""${REG_PATH}\${REG_PROP}"" = 1" Try { New-ItemProperty -Path $REG_PATH -Name $REG_PROP -PropertyType DWord -Value 1 | Out-Null } Catch { LogErr $_.Exception.Message } } -Else { LogMsg "The registry path already exists: ""${REG_PATH}\${REG_PROP}""" } +Else { Write-Output "The registry path already exists: ""${REG_PATH}\${REG_PROP}""" } diff --git a/Fix-SystemPrintQueue.ps1 b/Fix-SystemPrintQueue.ps1 index 8bb6310..86ca7dc 100644 --- a/Fix-SystemPrintQueue.ps1 +++ b/Fix-SystemPrintQueue.ps1 @@ -7,7 +7,7 @@ If (! ($(Get-Service -Name 'spooler').StartType -eq "Disabled") ) { Control-Service -Stop -Name $SERVICE ## Delete all print jobs - LogMsg "Deleting all print jobs from ""${Env:WINDIR}\System32\spool\PRINTERS""" + Write-Output "Deleting all print jobs from ""${Env:WINDIR}\System32\spool\PRINTERS""" Try { Remove-Item "${Env:WINDIR}\System32\spool\PRINTERS\*" -Recurse } Catch { LogErr $_.Exception.Message } diff --git a/Fix-WindowsHealth.ps1 b/Fix-WindowsHealth.ps1 index e0a7a37..9d05cd9 100644 --- a/Fix-WindowsHealth.ps1 +++ b/Fix-WindowsHealth.ps1 @@ -1,41 +1,40 @@ -$ScheduleCheckDisk = $false +# Run SFC to check the filesystem, convert the result from Unicode to UTF8, delete the intermediate $tempFile +$tempFile = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName()) +$(sfc.exe /scannow) | Out-File $tempFile +Set-Content -Path $tempFile -Value $(Get-Content -Path $tempFile -Encoding Unicode) -Encoding UTF8 +$SFCOutput = Get-Content -Path $tempFile +Remove-Item $tempFile -Force -ErrorAction SilentlyContinue -# Run the System File Checker to scan for and repair any problems with protected system files -LogMsg "Running System File Checker" -$SFCOutput = $(sfc /scannow) | Out-String -LogMsg $SFCOutput - -$SFCOutputWithSpaces = " W i n d o w s R e s o u r c e P r o t e c t i o n d i d n o t f i n d a n y i n t e g r i t y v i o l a t i o n s ." -$SFCOutputWithoutSpaces = "Windows Resource Protection did not find any integrity violations." -If ( !($SFCOutput -match $SFCOutputWithSpaces) -or !($SFCOutput -match $SFCOutputWithoutSpaces) ) { $ScheduleCheckDisk = $true } +# Examine $SFCOutput for integrity violations, if found make sure chkdsk runs at the next boot +If ( $SFCOutput -contains 'Windows Resource Protection did not find any integrity violations.' ) { $ScheduleCheckDisk = $false } Else { $ScheduleCheckDisk = $true } # Run enhanced DISM for Windows 8 and higher endpoints If ( IsWindowsVersion -ge "6.2" ) { - $BeginDISMRun = $(Get-Date).AddSeconds(-1) + $BeginDISMRun = (Get-Date) - LogMsg "Beginning repair of Windows Component Store" + Write-Output "Beginning repair of Windows Component Store" Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /restorehealth" -Wait - LogMsg "Beginning cleanup of superceded components in Windows Component Store" + Write-Output "Beginning cleanup of superceded components in Windows Component Store" Start-Process "dism.exe" -ArgumentList "/online /cleanup-image /startcomponentcleanup" -Wait $EndDISMRun = $(Get-Date).AddSeconds(1) # Adding results of DISM log file to this log file - LogMsg "Beginning Windows Component Store log data collection" + Write-Output "Beginning Windows Component Store log data collection" Get-Content -Path "${Env:WinDir}\Logs\DISM\dism.log" | Select-String -Pattern '^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})' | ForEach-Object { If ( ((Get-Date $_.Line.Substring(0,19)) -gt $BeginDISMRun) -and ((Get-Date $_.Line.Substring(0,19)) -le $EndDISMRun) ) { - LogMsg $_.Line + Write-Output $_.Line } } - LogMsg "Completed Windows Component Store log data collection" + Write-Output "Completed Windows Component Store log data collection" } -Else { LogMsg "Online image cleanup and restoration is only supported on Windows 8 and higher" } +Else { Write-Output "Online image cleanup and restoration is only supported on Windows 8 and higher" } # Schedule Check Disk if needed If ( $ScheduleCheckDisk ) { - LogMsg "Check Disk scheduled to repair disk at next boot" + Write-Output "Check Disk scheduled to repair disk at next boot" & echo y | chkdsk /F /R /X } \ No newline at end of file diff --git a/Fix-WindowsScriptingComponents.ps1 b/Fix-WindowsScriptingComponents.ps1 index 1e73fe7..ac7b8f0 100644 --- a/Fix-WindowsScriptingComponents.ps1 +++ b/Fix-WindowsScriptingComponents.ps1 @@ -1,4 +1,4 @@ -LogMsg "Fix-WindowsScriptingComponents.ps1" +Write-Output "Fix-WindowsScriptingComponents.ps1" ## List of all scripting component DLL files $DLL_FILES = @("${Env:WINDIR}\system32\vbscript.dll", @@ -22,7 +22,7 @@ ForEach ($dll in $DLL_FILES) If ( Test-Path $dll ) { If ( $dll -Match "syswow64" ) { $REGSVR32 = "${Env:WINDIR}\syswow64\regsvr32" } Else { $REGSVR32 = "regsvr32" } - LogMsg "Unregister: ${dll}" + Write-Output "Unregister: ${dll}" Try { Start-Process "${REGSVR32}" -ArgumentList "/u /s ${dll}" -Wait } Catch { LogErr $_.Exception.Message } } @@ -35,7 +35,7 @@ ForEach ($dll in $DLL_FILES) { If ( $dll -Match "syswow64" ) { $REGSVR32 = "${Env:WINDIR}\syswow64\regsvr32" } Else { $REGSVR32 = "regsvr32" } - LogMsg "Register: ${dll}" + Write-Output "Register: ${dll}" Try { Start-Process "${REGSVR32}" -ArgumentList "/s ${dll}" -Wait } Catch { LogErr $_.Exception.Message } } diff --git a/Fix-WindowsUpdate.ps1 b/Fix-WindowsUpdate.ps1 index 561723f..06ad03c 100644 --- a/Fix-WindowsUpdate.ps1 +++ b/Fix-WindowsUpdate.ps1 @@ -5,7 +5,7 @@ $TARGET_DIR = "${Env:WinDir}\SoftwareDistribution" $DEST_DIR = "${Env:WinDir}\SoftwareDistribution.old" ## Delete any existing folder from a previous execution of this script -LogMsg "Deleting ""${DEST_DIR}""" +Write-Output "Deleting ""${DEST_DIR}""" Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } @@ -14,7 +14,7 @@ Control-Service -Stop -Name BITS Control-Service -Stop -Name wuauserv ## Rename the SoftwareDistribution folder, forcing Windows Update to recreate all metrics and redownload all updates -LogMsg "Renaming ""${TARGET_DIR}"" to ""${DEST_DIR}""" +Write-Output "Renaming ""${TARGET_DIR}"" to ""${DEST_DIR}""" Try { Rename-Item -Path $TARGET_DIR -NewName $DEST_DIR -Force } Catch { LogErr $_.Exception.Message } @@ -25,11 +25,11 @@ Control-Service -Start -Name wuauserv ## Delete SoftwareDistribution.old from this execution of this script ## Comment this section out if you want to leave the renamed folder there for some reason, ## but keep in mind this folder can be very large and takes up a lot of space. -LogMsg "Deleting ""${DEST_DIR}""" +Write-Output "Deleting ""${DEST_DIR}""" Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } ## Force the Windows Update client to check for new updates -LogMsg "Resetting WSUS authorization and starting update detection" +Write-Output "Resetting WSUS authorization and starting update detection" Try { Start-Process "${Env:WinDir}\System32\wuauctl.exe" -ArgumentList "/resetauthorization /detectnow" } Catch { LogErr $_.Exception.Message } \ No newline at end of file diff --git a/Get-EventData.ps1 b/Get-EventData.ps1 index 5ac5feb..6c7dc0b 100644 --- a/Get-EventData.ps1 +++ b/Get-EventData.ps1 @@ -8,15 +8,15 @@ $ExportedEvents = "${Env:TEMP}\${Env:COMPUTERNAME}_events.csv" # Install Posh-SSH module If ( !(Get-Module -ListAvailable -Name Posh-SSH) ) { - LogMsg "Installing Posh-SSH module" + Write-Output "Installing Posh-SSH module" Install-Module -Name Posh-SSH -Force } # Cleanup previous runs If ( Test-Path $ExportedEvents ) { - LogMsg "Deleting exported events from previous script run ""${ExportedEvents}""" + Write-Output "Deleting exported events from previous script run ""${ExportedEvents}""" Try { Remove-Item $ExportedEvents -Force -ErrorAction Stop } - Catch { LogMsg "Cannot remove files from previous script execution. This script cannot run." ; Exit } + Catch { Write-Output "Cannot remove files from previous script execution. This script cannot run." ; Exit } } # Get all available log files @@ -25,13 +25,13 @@ $Logs = Get-WinEvent -ListLog * # Export all significant events from all available log files ForEach ($Log in $Logs) { $LogName = $Log.LogName - LogMsg "Exporting events from: ${LogName}" + Write-Output "Exporting events from: ${LogName}" Try { Get-WinEvent -LogName $LogName -FilterXPath "Event/System[Level=1 or Level=2 or Level=3]" -ErrorAction Stop | Select LogName,ProviderName,Level,Id,Message | Export-Csv -Path "${ExportedEvents}" -Append -NoTypeInformation -ErrorAction Stop } Catch { LogErr $_.Exception.Message } } # Deduplicate exported events -LogMsg "Deduplicating and sorting all exported events" +Write-Output "Deduplicating and sorting all exported events" Try { $TempEvents = Import-Csv $ExportedEvents -ErrorAction Stop | Sort-Object LogName,ProviderName,Id -Unique $TempEvents | Sort-Object -Property LogName,ProviderName | Export-Csv $ExportedEvents -NoTypeInformation -ErrorAction Stop @@ -48,7 +48,7 @@ If ( Test-Path $ExportedEvents ) { # Make the connection and upload the file $SFTPSession = New-SFTPSession -ComputerName $SFTPHost -Credential $SFTPCred -AcceptKey -Port $SFTPPort - LogMsg "Uploading events to SFTP site" + Write-Output "Uploading events to SFTP site" Try { Set-SFTPItem -SessionId $SFTPSession.SessionId -Path $ExportedEvents -Destination . -Force } Catch { LogErr $_.Exception.Message } Finally { Remove-SFTPSession -SessionId $SFTPSession.SessionId } @@ -56,5 +56,5 @@ If ( Test-Path $ExportedEvents ) { } # Cleanup -LogMsg "Deleting ""${ExportedEvents}""" +Write-Output "Deleting ""${ExportedEvents}""" Remove-Item $ExportedEvents -Force -ErrorAction SilentlyContinue \ No newline at end of file diff --git a/Get-InstalledSoftware.ps1 b/Get-InstalledSoftware.ps1 index a7e5985..b31c424 100644 --- a/Get-InstalledSoftware.ps1 +++ b/Get-InstalledSoftware.ps1 @@ -9,7 +9,7 @@ If ( Test-Path $FILE ) { Clear-Content -Path $FILE -Force } Function Write-LineToFile { param([Parameter(Mandatory=$true)][string]$Path,[Parameter(Mandatory=$true)][string]$Line) If ( -not (Test-Path $Path) ) { - LogMsg "Creating file ""${Path}""" + Write-Output "Creating file ""${Path}""" Try { New-Item -Path $Path -ItemType File -Force | Out-Null } Catch { LogErr $_.Exception.Message } } diff --git a/Install-4KVideoDownloader.ps1 b/Install-4KVideoDownloader.ps1 index 70ebcee..eee5d6f 100644 --- a/Install-4KVideoDownloader.ps1 +++ b/Install-4KVideoDownloader.ps1 @@ -8,13 +8,13 @@ If (! (Test-Path "${Env:ProgramFiles}\4KDownload\4kvideodownloader\4kvideodownlo $INSTALLER = Download-File -URL $URL ## Install the app - LogMsg "Installing 4K Video Downloader from ""${INSTALLER}""" + Write-Output "Installing 4K Video Downloader from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart" -Wait } Catch { LogErr $_.Exception.Message } ## Delete the installer - LogMsg "Deleting downloaded installer from ""${INSTALLER}""" + Write-Output "Deleting downloaded installer from ""${INSTALLER}""" Try { Remove-Item -Path $INSTALLER -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } -Else { LogMsg "4K Video Downloader is already installed!" } \ No newline at end of file +Else { Write-Output "4K Video Downloader is already installed!" } \ No newline at end of file diff --git a/Install-AdobeConnect.ps1 b/Install-AdobeConnect.ps1 index 76d2c0a..36177fe 100644 --- a/Install-AdobeConnect.ps1 +++ b/Install-AdobeConnect.ps1 @@ -3,8 +3,8 @@ $URL = 'https://download.adobe.com/pub/connect/updaters/meeting/11_0/ConnectApp1 ## Install Adobe Connect If ( IsURLValid $URL ) { - LogMsg "Installing Adobe Connect from ${URL}" + Write-Output "Installing Adobe Connect from ${URL}" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${URL} /qn /norestart" -Wait } Catch { LogErr $_.Exception.Message } } -Else { LogMsg "URL is not valid: ${URL}" } \ No newline at end of file +Else { Write-Output "URL is not valid: ${URL}" } \ No newline at end of file diff --git a/Install-AteraAgent.ps1 b/Install-AteraAgent.ps1 index b4b0efe..482b36e 100644 --- a/Install-AteraAgent.ps1 +++ b/Install-AteraAgent.ps1 @@ -18,7 +18,7 @@ $AGENT_INSTALLER = '{0}{1}' -f (Get-TempPath), $AGENT_FILENAME # Make sure we need to install the agent If ( (Test-Path "${Env:ProgramFiles}\ATERA Networks\AteraAgent\AteraAgent.exe") -or (Test-Path "${Env:ProgramFiles(x86)}\ATERA Networks\AteraAgent\AteraAgent.exe") ) -{ $INSTALL = $false ; $PreviousInstall = $true ; LogMsg "Atera agent is already installed on this endpoint" } Else { $INSTALL = $true ; $PreviousInstall = $false } +{ $INSTALL = $false ; $PreviousInstall = $true ; Write-Output "Atera agent is already installed on this endpoint" } Else { $INSTALL = $true ; $PreviousInstall = $false } If ( $FORCE ) { $INSTALL = $true } @@ -26,15 +26,15 @@ If ( $INSTALL ) { # Uninstall if $FORCE is true If ( $PreviousInstall ) { - LogMsg "Getting information from existing installation" + Write-Output "Getting information from existing installation" $ACCOUNT_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AccountId' -ErrorAction SilentlyContinue) $AGENT_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AgentId' -ErrorAction SilentlyContinue) $CUSTOMER_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'CompanyId' -ErrorAction SilentlyContinue) $INTEGRATOR_ID = (Get-ItemPropertyValue -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'IntegratorLogin' -ErrorAction SilentlyContinue) - LogMsg "AccountID : ${ACCOUNT_ID}" - LogMsg "AgentID : ${AGENT_ID}" - LogMsg "CustomerID : ${CUSTOMER_ID}" - LogMsg "IntegratorID: ${INTEGRATOR_ID}" + Write-Output "AccountID : ${ACCOUNT_ID}" + Write-Output "AgentID : ${AGENT_ID}" + Write-Output "CustomerID : ${CUSTOMER_ID}" + Write-Output "IntegratorID: ${INTEGRATOR_ID}" #Download and run the uninstall script $UninstallScript = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Uninstall-AteraAgent.ps1' @@ -49,23 +49,23 @@ If ( $INSTALL ) { Download-File -URL "https://app.atera.com/GetAgent/Msi/?customerId=${CUSTOMER_ID}&integratorLogin=${INTEGRATOR_ID}" -File "${AGENT_INSTALLER}" # Install the agent - LogMsg "Installing Atera agent from ""${AGENT_INSTALLER}""" + Write-Output "Installing Atera agent from ""${AGENT_INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait } Catch { LogErr $_.Exception.Message } # Delete the agent installer - LogMsg "Deleting ""${AGENT_INSTALLER}""" + Write-Output "Deleting ""${AGENT_INSTALLER}""" Try { Remove-Item $AGENT_INSTALLER -Force } Catch { LogErr $_.Exception.Message } If ( $PreviousInstall -and $ACCOUNT_ID -and $AGENT_ID -and $CUSTOMER_ID) { - LogMsg "Restoring agent information from previous install" - LogMsg " - Stopping AteraAgent service" + Write-Output "Restoring agent information from previous install" + Write-Output " - Stopping AteraAgent service" Stop-Service -Name 'AteraAgent' -Force - LogMsg " - Restoring AgentID and AccountID from previous install" + Write-Output " - Restoring AgentID and AccountID from previous install" Set-ItemProperty -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AccountId' -Value $ACCOUNT_ID Set-ItemProperty -Path 'HKLM:SOFTWARE\ATERA Networks\AlphaAgent' -Name 'AgentId' -Value $AGENT_ID - LogMsg " - Starting AteraAgent service" + Write-Output " - Starting AteraAgent service" Start-Service -Name 'AteraAgent' } diff --git a/Install-DeltekVision.ps1 b/Install-DeltekVision.ps1 index f2137c9..59ebaa4 100644 --- a/Install-DeltekVision.ps1 +++ b/Install-DeltekVision.ps1 @@ -1,7 +1,7 @@ $SHORTCUT_PATH = "${Env:Public}\Desktop\Deltek Vision.lnk" # Remove the shortcut if it already exists -If ( Test-Path $SHORTCUT_PATH ) { LogMsg "Removing existing shortcut: ${SHORTCUT_PATH}" ; Remove-Item $SHORTCUT_PATH } +If ( Test-Path $SHORTCUT_PATH ) { Write-Output "Removing existing shortcut: ${SHORTCUT_PATH}" ; Remove-Item $SHORTCUT_PATH } # If the shortcut doesn't exist If ( -not (Test-Path $SHORTCUT_PATH) ) { @@ -28,10 +28,10 @@ If ( -not (Test-Path $SHORTCUT_PATH) ) { ## Create the shortcut If ( $BROWSER_PATH ) { - LogMsg "Installing Deltek Vision for ${APP_NAME}" + Write-Output "Installing Deltek Vision for ${APP_NAME}" Create-Shortcut -Path "${Env:Public}\Desktop\Deltek Vision.lnk" -TargetPath $BROWSER_PATH -Arguments $VisionURL -Description "Launch Deltek Vision" } - Else { LogMsg "A compatible browser could not be found: ${BROWSER_PATH}" } + Else { Write-Output "A compatible browser could not be found: ${BROWSER_PATH}" } } - Else { LogMsg "No URL to Deltek Vision was specified!" } + Else { Write-Output "No URL to Deltek Vision was specified!" } } diff --git a/Install-DisplayLink.ps1 b/Install-DisplayLink.ps1 index ba4e6d2..745c9cb 100644 --- a/Install-DisplayLink.ps1 +++ b/Install-DisplayLink.ps1 @@ -14,7 +14,7 @@ ElseIf ( (IsWindowsVersion -ge "6.1") -and (IsWindowsVersion -lt "10.0") ) If ( Is64bit ) { $URL = '{0}/{1}' -f $BaseURL, 'DisplayLink_Win7-8.1_x64.msi' } Else { $URL = '{0}/{1}' -f $BaseURL, 'DisplayLink_Win7-8.1_x86.msi' } } -Else { LogMsg "Operating system is not supported" ; Exit } +Else { Write-Output "Operating system is not supported" ; Exit } ## Install DisplayLink Install-Program -Path "msiexec.exe" -Arguments "/i ${URL} /qn /norestart" diff --git a/Install-ESETManagementAgent.ps1 b/Install-ESETManagementAgent.ps1 index bc8adee..5680993 100644 --- a/Install-ESETManagementAgent.ps1 +++ b/Install-ESETManagementAgent.ps1 @@ -5,19 +5,19 @@ $TEMPDIR = '{0}eset-protect-deployment' -f (Get-TempPath) # Recursively delete $TEMPDIR if it already exists If ( Test-Path $TEMPDIR ) { - LogMsg """${TEMPDIR}"" already exists and will be deleted" + Write-Output """${TEMPDIR}"" already exists and will be deleted" Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } } # Create $TEMPDIR -LogMsg "Creating: ${TEMPDIR}" +Write-Output "Creating: ${TEMPDIR}" Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop } Catch { LogErr $_.Exception.Message ; Exit } # Write $CONFIG to install_config.ini Try { $CONFIG | WriteToFile_UTF8NoBOM -FilePath "${TEMPDIR}\install_config.ini" } -Catch { LogMsg "Cannot write configuration file! This script will exit." ; LogErr $_.Exception.Message ; Exit } +Catch { Write-Output "Cannot write configuration file! This script will exit." ; LogErr $_.Exception.Message ; Exit } # Get bitness of endpoint and set $AGENTNAME If ( Is64bit ) { $AGENTNAME = "agent_x64.msi" } Else { $AGENTNAME = "agent_x86.msi" } @@ -25,15 +25,15 @@ If ( Is64bit ) { $AGENTNAME = "agent_x64.msi" } Else { $AGENTNAME = "agent_x86.m # Download the installer $INSTALLER = "${TEMPDIR}\${AGENTNAME}" $URL = 'https://download.eset.com/com/eset/apps/business/era/agent/latest/{0}' -f $AGENTNAME -LogMsg "Downloading ESET Management Agent" +Write-Output "Downloading ESET Management Agent" Download-File -URL $URL -File $INSTALLER # Install the app -LogMsg "Installing ESET Management Agent from ""${INSTALLER}""" +Write-Output "Installing ESET Management Agent from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart /log installer.log" -Wait } Catch { LogErr $_.Exception.Message } # Delete the installer -LogMsg "Deleting temp directory and its contents" +Write-Output "Deleting temp directory and its contents" Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } diff --git a/Install-EmberkomCloudBackup.ps1 b/Install-EmberkomCloudBackup.ps1 index 904a91e..f290cbd 100644 --- a/Install-EmberkomCloudBackup.ps1 +++ b/Install-EmberkomCloudBackup.ps1 @@ -23,21 +23,21 @@ Import-Module -Name MSP360 $Installer = Download-File -URL $URL # Install the agent -LogMsg "Installing Emberkom Cloud Backup agent" +Write-Output "Installing Emberkom Cloud Backup agent" Try { Start-Process "${Installer}" -ArgumentList "/S" -Wait } Catch { LogErr $_.Exception.Message } # Add backup user to installed product Try { $MSP360Password = ConvertTo-SecureString -string $MSP360Password -AsPlainText -Force - LogMsg "Adding backup user account: ${MSP360Username}" + Write-Output "Adding backup user account: ${MSP360Username}" Add-MBSUserAccount -User $MSP360Username -Password $MSP360Password } Catch { LogErr $_.Exception.Message } # Set the agent edition # Note: the product edition must be set *after* the user is added -LogMsg "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition""" +Write-Output "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition""" Try { Set-MBSAgentSetting -Edition $AgentEdition -Verbose } Catch { LogErr $_.Exception.Message } diff --git a/Install-Enscape.ps1 b/Install-Enscape.ps1 index 978f51c..8de0991 100644 --- a/Install-Enscape.ps1 +++ b/Install-Enscape.ps1 @@ -3,13 +3,13 @@ $MSIURL = 'https://enscape-installer.chaosgroup.com/installer.enscape.io/Enscape ## Run the installer $INSTALLER = Download-File -URL $MSIURL -LogMsg "Installing Enscape from ""${INSTALLER}""" +Write-Output "Installing Enscape from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart ACCEPTEULA=1 ALLUSERS=1" -Wait -ErrorAction Stop } Catch { LogErr $_.Exception.Message } ## Delete installer Try { - LogMsg "Deleting downloaded installation package" + Write-Output "Deleting downloaded installation package" Remove-Item $INSTALLER -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } diff --git a/Install-LiquidFilesOutlookAgent.ps1 b/Install-LiquidFilesOutlookAgent.ps1 index 42ce244..b817086 100644 --- a/Install-LiquidFilesOutlookAgent.ps1 +++ b/Install-LiquidFilesOutlookAgent.ps1 @@ -3,7 +3,7 @@ $MSIURL = 'https://lfupdate.s3.amazonaws.com/clients/outlook/admin_msi/LiquidFil # Set installer args If (-not [string]::IsNullOrEmpty($LFHost) ) { - LogMsg "LiquidFiles target server: ${LFHost}" + Write-Output "LiquidFiles target server: ${LFHost}" $INSTALLER_ARGS = "REGKEYSCRIPT=""BaseUrl=${LFHost};InjectPositionDefault=3""" } Else { $INSTALLER_ARGS = '' } @@ -11,7 +11,7 @@ Else { $INSTALLER_ARGS = '' } # Stop any running LiquidFilesWindowsAgent process $RunningProcess = Get-Process -Name "LiquidFilesWindowsAgent" If ($RunningProcess) { - LogMsg "Stopping the LiquidFiles agent" + Write-Output "Stopping the LiquidFiles agent" $RunningProcess | Stop-Process -Force } @@ -20,13 +20,13 @@ If ($RunningProcess) { # Run the installer $INSTALLER = Download-File -URL $MSIURL -LogMsg "Installing Liquid Files Outlook Agent from ""${INSTALLER}""" +Write-Output "Installing Liquid Files Outlook Agent from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart ${INSTALLER_ARGS}" -Wait -ErrorAction Stop } Catch { LogErr $_.Exception.Message } # Delete installer Try { - LogMsg "Deleting downloaded installation package" + Write-Output "Deleting downloaded installation package" Remove-Item $INSTALLER -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } @@ -40,7 +40,7 @@ If ( Test-Path $PathToAgentExe64 ) { $PathToAgentExe = $PathToAgentExe32 } If ($PathToAgentExe) { - LogMsg "Starting LiquidFiles agent" + Write-Output "Starting LiquidFiles agent" Try { Start-Process $PathToAgentExe } Catch { LogErr $_.Exception.Message } } diff --git a/Install-ManagementAgent.ps1 b/Install-ManagementAgent.ps1 index 5015964..3525b8d 100644 --- a/Install-ManagementAgent.ps1 +++ b/Install-ManagementAgent.ps1 @@ -27,5 +27,5 @@ If ( !(Test-Path $AGENT_EXE) ) ## Install the agent Install-Program $AGENT_INSTALLER -Arguments "/s /v"" /qn CUSTOMERID=${CUSTOMER_ID} CUSTOMERSPECIFIC=1 REGISTRATION_TOKEN=${TOKEN} SERVERPROTOCOL=HTTPS SERVERADDRESS=${SERVER} SERVERPORT=443""" -Delete -} Else { LogMsg "N-Central agent is already installed on this endpoint." } +} Else { Write-Output "N-Central agent is already installed on this endpoint." } diff --git a/Install-Nextcloud.ps1 b/Install-Nextcloud.ps1 index 65b1152..95658f1 100644 --- a/Install-Nextcloud.ps1 +++ b/Install-Nextcloud.ps1 @@ -16,7 +16,7 @@ Install-Program -Path $(Download-File -URL $URL) -Arguments "/S" -Delete ## Start the app after installation If ( Test-Path $InstallPath ) { - LogMsg "Starting Nextcloud" + Write-Output "Starting Nextcloud" Try { Start-Process $InstallPath } Catch { LogErr $_.Exception.Message } } diff --git a/Install-OpenVPN.ps1 b/Install-OpenVPN.ps1 index be9c814..fc5dc0c 100644 --- a/Install-OpenVPN.ps1 +++ b/Install-OpenVPN.ps1 @@ -19,9 +19,9 @@ If ( IsAdmin ) Else { $Shortcut = "${Env:SYSTEMDRIVE}\Users\Public\Desktop\OpenVPN GUI.LNK" } If ( Test-Path $Shortcut ) { - LogMsg "Deleting desktop shortcut: ${Shortcut}" + Write-Output "Deleting desktop shortcut: ${Shortcut}" Try { Remove-Item $Shortcut -Force } Catch { LogErr $_.Exception.Message } } } -Else { LogMsg "Must be an administrator to install OpenVPN" } \ No newline at end of file +Else { Write-Output "Must be an administrator to install OpenVPN" } \ No newline at end of file diff --git a/Install-SimpleInOut.ps1 b/Install-SimpleInOut.ps1 index f32691e..e2598bb 100644 --- a/Install-SimpleInOut.ps1 +++ b/Install-SimpleInOut.ps1 @@ -1,4 +1,4 @@ -If ( Test-Path "${Env:ProgramFiles}\simpleinout-desktop\Simple In Out.exe" ) { LogMsg "Simple In/Out is already installed." ; Exit } +If ( Test-Path "${Env:ProgramFiles}\simpleinout-desktop\Simple In Out.exe" ) { Write-Output "Simple In/Out is already installed." ; Exit } # Specify the URL to download the app from $URL = 'https://downloads.simpleinout.com/desktop/Simple-In-Out.msi' @@ -7,11 +7,11 @@ $URL = 'https://downloads.simpleinout.com/desktop/Simple-In-Out.msi' $INSTALLER = Download-File -URL $URL # Install the app -LogMsg "Installing latest version of Simple In/Out from ""${INSTALLER}""" +Write-Output "Installing latest version of Simple In/Out from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart ALLUSERS=1" -Wait } Catch { LogErr $_.Exception.Message } # Delete the installer -LogMsg "Deleting downloaded installer from ""${INSTALLER}""" +Write-Output "Deleting downloaded installer from ""${INSTALLER}""" Try { Remove-Item -Path $INSTALLER -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } \ No newline at end of file diff --git a/Install-SpecsIntact.ps1 b/Install-SpecsIntact.ps1 index 8d3774f..ac5394e 100644 --- a/Install-SpecsIntact.ps1 +++ b/Install-SpecsIntact.ps1 @@ -5,11 +5,11 @@ $URL = 'https://specsintact.ksc.nasa.gov/Software/downloads/SpecsIntact.msi' $INSTALLER = Download-File -URL $URL ## Install the app -LogMsg "Installing latest version of SpecsIntact from ""${INSTALLER}""" +Write-Output "Installing latest version of SpecsIntact from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart" -Wait } Catch { LogErr $_.Exception.Message } ## Delete the installer -LogMsg "Deleting downloaded installer from ""${INSTALLER}""" +Write-Output "Deleting downloaded installer from ""${INSTALLER}""" Try { Remove-Item -Path $INSTALLER -Force -ErrorAction SilentlyContinue } Catch { LogErr $_.Exception.Message } \ No newline at end of file diff --git a/Install-SyncroAgent.ps1 b/Install-SyncroAgent.ps1 index 0eb8a2c..3a73bf2 100644 --- a/Install-SyncroAgent.ps1 +++ b/Install-SyncroAgent.ps1 @@ -21,11 +21,11 @@ $AGENT_INSTALLER = '{0}{1}' -f (Get-TempPath), $AGENT_FILENAME Download-File -URL $URL -File "${AGENT_INSTALLER}" # Install the agent - LogMsg "Installing Syncro agent from ""${AGENT_INSTALLER}""" + Write-Output "Installing Syncro agent from ""${AGENT_INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait } Catch { LogErr $_.Exception.Message } # Delete the agent installer - LogMsg "Deleting ""${AGENT_INSTALLER}""" + Write-Output "Deleting ""${AGENT_INSTALLER}""" Try { Remove-Item $AGENT_INSTALLER -Force } Catch { LogErr $_.Exception.Message } \ No newline at end of file diff --git a/Install-VLC.ps1 b/Install-VLC.ps1 index 3c8f13c..11b6636 100644 --- a/Install-VLC.ps1 +++ b/Install-VLC.ps1 @@ -10,4 +10,4 @@ If ( IsAdmin ) If ( $Installer ) { Install-Program -Path "${Installer}" -Arguments "/S" -Delete } } -Else { LogMsg "Must be an administrator to install VLC" } \ No newline at end of file +Else { Write-Output "Must be an administrator to install VLC" } \ No newline at end of file diff --git a/Install-Wireguard.ps1 b/Install-Wireguard.ps1 index 3a4f3ba..7fead4e 100644 --- a/Install-Wireguard.ps1 +++ b/Install-Wireguard.ps1 @@ -25,4 +25,4 @@ If ( IsAdmin ) Create-Shortcut -Path "${Env:Public}\Desktop\WireGuard VPN.LNK" -TargetPath "${Env:ProgramFiles}\WireGuard\wireguard.exe" -Description "WireGuard: Fast, Modern, Secure VPN Tunnel" } } -Else { LogMsg "Must be an administrator to install WireGuard" } \ No newline at end of file +Else { Write-Output "Must be an administrator to install WireGuard" } \ No newline at end of file diff --git a/Install-ZeroTier.ps1 b/Install-ZeroTier.ps1 index ffe0e90..1330781 100644 --- a/Install-ZeroTier.ps1 +++ b/Install-ZeroTier.ps1 @@ -20,7 +20,7 @@ If ( IsWindowsVersion -ge "6.1" ) ## Check to make sure the ZeroTierOneService has started ## We'll only loop through this for a few seconds before failing - LogMsg "Attempting to start the ZeroTierOneService service..." + Write-Output "Attempting to start the ZeroTierOneService service..." For ( $i = 1 ; $i -le 5 ; $i++ ) { ## Check to see if the service is running @@ -37,7 +37,7 @@ If ( IsWindowsVersion -ge "6.1" ) ## If the service is running, break the loop Else { - LogMsg " ZeroTierOneService service is started" + Write-Output " ZeroTierOneService service is started" $ServiceRunning = $true ; break } } @@ -54,27 +54,27 @@ If ( IsWindowsVersion -ge "6.1" ) If ( Test-Path "${ZTcli}" ) { ## Join the network, if $ZTcli exists - LogMsg "Joining ZeroTier network ${JoinNetwork}" + Write-Output "Joining ZeroTier network ${JoinNetwork}" Try { Start-Process $ZTcli -ArgumentList "join ${JoinNetwork}" -Wait } Catch { LogErr $_.Exception.Message } } - Else { LogMsg "Could not find ""${ZTcli}""" } + Else { Write-Output "Could not find ""${ZTcli}""" } } ## If the service still isn't running, just error out - Else { LogMsg " ZeroTierOneService could not be started in a timely fashion" } + Else { Write-Output " ZeroTierOneService could not be started in a timely fashion" } } - Else { LogMsg "A ZeroTier network ID was not specified, will not join any network" } + Else { Write-Output "A ZeroTier network ID was not specified, will not join any network" } ## Remove the ZeroTier One Start Menu shortcut $ShortcutPath = "${ProgramData}\Microsoft\Windows\Start Menu\Programs\ZeroTier One.lnk" If ( Test-Path $ShortcutPath ) { - LogMsg "Deleting Start Menu shortcut from ""${ShortcutPath}""" + Write-Output "Deleting Start Menu shortcut from ""${ShortcutPath}""" Try { Remove-Item $ShortcutPath -Force } Catch { LogErr $_.Exception.Message } } } -Else { LogMsg "ZeroTier can only be installed on Windows 7 or higher operating systems" } +Else { Write-Output "ZeroTier can only be installed on Windows 7 or higher operating systems" } diff --git a/Remove-DeltekVision.ps1 b/Remove-DeltekVision.ps1 index fdba0d1..172c7b5 100644 --- a/Remove-DeltekVision.ps1 +++ b/Remove-DeltekVision.ps1 @@ -5,8 +5,8 @@ End-Process -Name "DeltekVision" -Force $APP_PATH = "${Env:UserProfile}\AppData\Local\Apps\2.0" If ( Test-Path $APP_PATH ) { ## Delete the existing installed app - LogMsg "Deleting ""${APP_PATH}""" + Write-Output "Deleting ""${APP_PATH}""" Try { Remove-Item $APP_PATH -Recurse -Force } Catch { LogErr $_.Exception.Message } -} Else { LogMsg "The path specified does not exist: ${APP_PATH}" } \ No newline at end of file +} Else { Write-Output "The path specified does not exist: ${APP_PATH}" } \ No newline at end of file diff --git a/Remove-OldFiles.ps1 b/Remove-OldFiles.ps1 index 14e6cd3..08829a4 100644 --- a/Remove-OldFiles.ps1 +++ b/Remove-OldFiles.ps1 @@ -3,12 +3,12 @@ If ( $OlderThanDays -is [int] ) { If ( Test-Path $Path ) { - LogMsg "Deleting all items older than ${OlderThanDays} days in ""${Path}""" + Write-Output "Deleting all items older than ${OlderThanDays} days in ""${Path}""" $files = Get-ChildItem $Path | Where { !$_.PSIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-${OlderThanDays}) } Foreach ( $f in $files ) { - $msg = "Deleting {0}" -f $f.FullName ; LogMsg $msg + $msg = "Deleting {0}" -f $f.FullName ; Write-Output $msg Try { Remove-Item $f -Force | Out-Null } Catch { LogErr $_.Exception.Message } } - } Else { LogMsg "Path does not exist: ""${Path}""" } -} Else { LogMsg "The value entered for ""OlderThanDays"" is not an integer" } \ No newline at end of file + } Else { Write-Output "Path does not exist: ""${Path}""" } +} Else { Write-Output "The value entered for ""OlderThanDays"" is not an integer" } \ No newline at end of file diff --git a/Remove-OldRevitLocals.ps1 b/Remove-OldRevitLocals.ps1 index 1d89230..b9a7ba5 100644 --- a/Remove-OldRevitLocals.ps1 +++ b/Remove-OldRevitLocals.ps1 @@ -21,7 +21,7 @@ ForEach ( $path in $RevitLocalPaths ) { # Only remove Revit local files that have worksharing enabled If ( (Test-Path "${revitfile}") -and (Test-Path "${BackupDir}")) { - LogMsg "Deleting ""${revitfile}"" and backup directory ""${BackupDir}""" + Write-Output "Deleting ""${revitfile}"" and backup directory ""${BackupDir}""" Remove-Item "${revitfile}" -Force -ErrorAction SilentlyContinue Remove-Item "${BackupDir}" -Recurse -ErrorAction SilentlyContinue } diff --git a/Start-Windows10UpdateAssistant.ps1 b/Start-Windows10UpdateAssistant.ps1 index 7da4ec3..055cf8e 100644 --- a/Start-Windows10UpdateAssistant.ps1 +++ b/Start-Windows10UpdateAssistant.ps1 @@ -13,34 +13,34 @@ If ( IsWindowsVersion -ge "10.0" ) { ## Uninstall previous Windows 10 Update Assistant If ( Test-Path "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" ) { - LogMsg "Uninstalling existing Windows 10 Update Assistant" + Write-Output "Uninstalling existing Windows 10 Update Assistant" Try { Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } } ## Download Windows 10 Update Assistant $FILENAME = Split-Path $URL -leaf If ( Test-Path "${DOWNLOADS}\${FILENAME}" ) { - LogMsg "Deleting existing installer: ${DOWNLOADS}\${FILENAME}" + Write-Output "Deleting existing installer: ${DOWNLOADS}\${FILENAME}" Try { Remove-Item "${DOWNLOADS}\${FILENAME}" -Force -ErrorAction SilentlyContinue } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } } - LogMsg "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}" + Write-Output "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}" Try { (New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}") } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } ## Install and run the Windows 10 Update Assistant If ( Test-Path "${DOWNLOADS}\${FILENAME}" ) { - LogMsg "Launching installer: ${DOWNLOADS}\${FILENAME}" + Write-Output "Launching installer: ${DOWNLOADS}\${FILENAME}" Try { Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } } - Else { LogMsg "${DOWNLOADS}\${FILENAME} does not exist" } + Else { Write-Output "${DOWNLOADS}\${FILENAME} does not exist" } } - Else { LogMsg "This endpoint is already up to date." } + Else { Write-Output "This endpoint is already up to date." } } -Else { LogMsg "This endpoint is not running Windows 10." } +Else { Write-Output "This endpoint is not running Windows 10." } diff --git a/Test-InternetBandwidth.ps1 b/Test-InternetBandwidth.ps1 index 6c675ab..1acdaa3 100644 --- a/Test-InternetBandwidth.ps1 +++ b/Test-InternetBandwidth.ps1 @@ -7,11 +7,11 @@ $ZIPFILE = Download-File -URL $URL ## Setup the directory to extract the downloaded zip file to $WORKINGDIR = $ZIPFILE.Substring(0, $ZIPFILE.LastIndexOf('.')) If ( Test-Path $WORKINGDIR ) { - LogMsg "Deleting existing directory: ""$WORKINGDIR""" + Write-Output "Deleting existing directory: ""$WORKINGDIR""" Try { Remove-Item -Path $WORKINGDIR -Recurse -Force } Catch { LogErr $_.Exception.Message } } -LogMsg "Creating new directory: ""$WORKINGDIR""" +Write-Output "Creating new directory: ""$WORKINGDIR""" Try { New-Item -Path $WORKINGDIR -ItemType Directory -Force | Out-Null } Catch { LogErr $_.Exception.Message } @@ -27,7 +27,7 @@ $SPEEDTEST = "${WORKINGDIR}\speedtest.exe" If ( Test-Path $SPEEDTEST ) { Try { - LogMsg "Starting internet bandwidth test" + Write-Output "Starting internet bandwidth test" $RESULTS = [string]( cmd.exe /c ""${SPEEDTEST} --accept-license --progress=no"" ) ## Cleanup the output @@ -41,22 +41,22 @@ If ( Test-Path $SPEEDTEST ) { $RESULTS = $RESULTS -replace "Result URL: ", "`nResult URL: " $RESULTS = $RESULTS + "`n" } Else { $RESULTS = "The test did not product any output" } - LogMsg $RESULTS - LogMsg "Finished internet bandwidth test" + Write-Output $RESULTS + Write-Output "Finished internet bandwidth test" } Catch { LogErr $_.Exception.Message } -} Else { LogMsg "The file does not exist at the expected path: ""${SPEEDTEST}""" } +} Else { Write-Output "The file does not exist at the expected path: ""${SPEEDTEST}""" } ## Cleanup files and directories created by this script If ( Test-Path $ZIPFILE ) { - LogMsg "Deleting downloaded zip file: ""$ZIPFILE""" + Write-Output "Deleting downloaded zip file: ""$ZIPFILE""" Try { Remove-Item -Path $ZIPFILE -Force } Catch { LogErr $_.Exception.Message } -} Else { LogMsg "Downloaded zip file no longer exists: ""$ZIPFILE""" } +} Else { Write-Output "Downloaded zip file no longer exists: ""$ZIPFILE""" } If ( Test-Path $WORKINGDIR ) { - LogMsg "Deleting directory from extracted zip file: ""$WORKINGDIR""" + Write-Output "Deleting directory from extracted zip file: ""$WORKINGDIR""" Try { Remove-Item -Path $WORKINGDIR -Recurse -Force } Catch { LogErr $_.Exception.Message } -} Else { LogMsg "Directory from extracted zip file no longer exists: ""$WORKINGDIR""" } \ No newline at end of file +} Else { Write-Output "Directory from extracted zip file no longer exists: ""$WORKINGDIR""" } \ No newline at end of file diff --git a/Tools.ps1 b/Tools.ps1 index 00e612a..cc8a130 100644 --- a/Tools.ps1 +++ b/Tools.ps1 @@ -1,7 +1,7 @@ -## Define the MSP name +# Define the MSP name [string]$Global:MSPName = "Emberkom" -## This section will define several global variables that can be used in scripts that source this one +# This section will define several global variables that can be used in scripts that source this one [string]$Global:RootDirectory [string]$Global:ScriptsDirectory [string]$Global:OutputDirectory @@ -12,7 +12,7 @@ # Define the root path for the MSP in the Windows Registry [string]$Global:MSPRegistryRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\${MSPName}" -## Setup the MSP management directories +# Setup the MSP management directories Function Setup-MSPDirectories { If ( Test-Path ${Env:ProgramData} ) { $Global:RootDirectory = "${Env:ProgramData}\${MSPName}" } Else { $Global:RootDirectory = "${Env:SystemDrive}\${MSPName}" } $Global:ScriptsDirectory = "${RootDirectory}\Scripts" @@ -20,7 +20,7 @@ Function Setup-MSPDirectories { $Global:ToolsDirectory = "${RootDirectory}\Tools" $Global:LogsDirectory = "${RootDirectory}\Logs" - ## Make sure all the management directories exist + # Make sure all the management directories exist $RootDirectory, $ScriptsDirectory, $OutputDirectory, $ToolsDirectory, $LogsDirectory | ForEach-Object { If ( !(Test-Path $_) ) { Try { New-Item -Path $_ -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null } @@ -29,18 +29,18 @@ Function Setup-MSPDirectories { } } -## Function to get a datestamp for right now in a long format +# Function to get a datestamp for right now in a long format Function Get-LongDateTime { Return $(Get-Date -Format "yyyyMMddHHmmssffff") } -## Setup the log file for messages generated when this script is run +# Setup the log file for messages generated when this script is run Function Setup-LogFile { $LogFilePrefix = "ManagementScript" $LogFilePostfix = Get-LongDateTime $Global:LogFile = "${LogsDirectory}\${LogFilePrefix}_${LogFilePostfix}.log" - ## Delete log files older than 120 days + # Delete log files older than 120 days $LogFileAllowedAge = (Get-Date).AddDays(-120) Try { Get-ChildItem -Path "${LogsDirectory}\${LogFilePrefix}_*.*" -Filter '*.log' | ` @@ -53,51 +53,51 @@ Function Setup-LogFile { Catch { Write-Output $_.Exception.Message } } -## Log a message to the log file -Function LogMsg { +# Log a message to the log file +Function Write-Output { param([Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Message) $Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $LogEntry = "${Timestamp} - ${Message}" Add-Content -Path $Global:LogFile -Value $LogEntry } -## Log an error to the log file -Function LogErr { +# Log an error to the log file +Function Write-Error { param([Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Message) $Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $LogEntry = "${Timestamp} - Error: ${Message}" Add-Content -Path $Global:LogFile -Value $LogEntry } -## Function to determine if the current user context is an Administrator +# Function to determine if the current user context is an Administrator Function IsAdmin { If ( ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) ) { Return $true } Else { Return $false } } -## Run a script from the live repo or from a local path +# Run a script from the live repo or from a local path Function Run-Script { param( - ## Parameters for live-ps scripts + # Parameters for live-ps scripts [Parameter(Mandatory=$false,ParameterSetName='live-ps')] [string]$Type='management-scripts', [Parameter(Mandatory=$true,ParameterSetName='live-ps')] [string]$LivePSScript, - ## Parameters for local scripts + # Parameters for local scripts [Parameter(Mandatory=$true,ParameterSetName='local')] [string]$Path, - #### $NoWait will prevent waiting for the specified script to finish running + ### $NoWait will prevent waiting for the specified script to finish running [Parameter(Mandatory=$false,ParameterSetName='local')] [switch]$NoWait=$false, - ## Parameters for all scripts + # Parameters for all scripts [Parameter(Mandatory=$false,ParameterSetName='live-ps')] [Parameter(Mandatory=$false,ParameterSetName='local')] [string]$Arguments='null', - #### $HaltIfRunning is a collection of app names which, if running, will prevent the script from running + ### $HaltIfRunning is a collection of app names which, if running, will prevent the script from running [Parameter(Mandatory=$false,ParameterSetName='live-ps')] [Parameter(Mandatory=$false,ParameterSetName='local')] [string[]]$HaltIfRunning='null', - #### $ForceClose will forcefully close all apps specified in $HaltIfRunning + ### $ForceClose will forcefully close all apps specified in $HaltIfRunning [Parameter(Mandatory=$false,ParameterSetName='live-ps')] [Parameter(Mandatory=$false,ParameterSetName='local')] [switch]$ForceClose=$false @@ -106,63 +106,63 @@ Function Run-Script { If ( $HaltIfRunning -eq "null" ) { $HaltIfRunning = $null } If ( $LivePSScript ) { $URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${LivePSScript}.ps1" - If ( !(IsURLValid -URL $URL) ) { LogMsg "The specified script does not exist: ${LivePSScript}" ; Exit } + If ( !(IsURLValid -URL $URL) ) { Write-Output "The specified script does not exist: ${LivePSScript}" ; Exit } } - If ( $Path ) { If ( !(Test-Path $Path) ) { LogMsg "The specified script does not exist: ""${Path}""" ; Exit } } - If ( ($null -ne $HaltIfRunning ) -and ($ForceClose) -and ( !(IsAdmin) ) ) { LogMsg "Cannot close dependent apps because this task does not have administrative privileges" ; Exit } + If ( $Path ) { If ( !(Test-Path $Path) ) { Write-Output "The specified script does not exist: ""${Path}""" ; Exit } } + If ( ($null -ne $HaltIfRunning ) -and ($ForceClose) -and ( !(IsAdmin) ) ) { Write-Output "Cannot close dependent apps because this task does not have administrative privileges" ; Exit } If ( $HaltIfRunning ) { $Halt = $false - LogMsg "Checking for running instances of the following dependent apps:" + Write-Output "Checking for running instances of the following dependent apps:" ForEach ( $name in $HaltIfRunning) { $RunningInstances = Get-Process | Where-Object { $_.Name -like "${name}" } If ( $RunningInstances ) { If ( $ForceClose -eq $true ) { - Try { $name | Stop-Process -Force ; LogMsg " ""${name}"" (force closed)" } - Catch { LogErr $_.Exception.Message ; Exit } + Try { $name | Stop-Process -Force ; Write-Output " ""${name}"" (force closed)" } + Catch { Write-Error $_.Exception.Message ; Exit } } - Else { $Halt = $true ; LogMsg " ""${name}"" (running)" } + Else { $Halt = $true ; Write-Output " ""${name}"" (running)" } } - Else { LogMsg " ""${name}"" (not running)" } + Else { Write-Output " ""${name}"" (not running)" } } - If ( $Halt -eq $true ) { LogMsg "Dependent apps are currently in use and are preventing the specified script from running" ; Exit } + If ( $Halt -eq $true ) { Write-Output "Dependent apps are currently in use and are preventing the specified script from running" ; Exit } } switch ($PSCmdlet.ParameterSetName) { 'live-ps' { - LogMsg "Retrieving : ${LivePSScript}.ps1" + Write-Output "Retrieving : ${LivePSScript}.ps1" Try { $Script = (New-Object Net.WebClient).DownloadString($URL) } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } Try { $ScriptBlock = [Scriptblock]::Create($Script) } - Catch { LogErr $_.Exception.Message ; Exit } - LogMsg "Executing: ${LivePSScript}.ps1 ${Arguments}" + Catch { Write-Error $_.Exception.Message ; Exit } + Write-Output "Executing: ${LivePSScript}.ps1 ${Arguments}" Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } } 'local' { - LogMsg "Executing: ${Path} ${Arguments}" + Write-Output "Executing: ${Path} ${Arguments}" If ( $NoWait ) { Try { Start-Process "${Path}" -ArgumentList "{$Arguments}" } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { - LogMsg " Waiting for script to finish..." + Write-Output " Waiting for script to finish..." Try { Start-Process "${Path}" -ArgumentList "{$Arguments}" -Wait } - Catch { LogErr $_.Exception.Message } - LogMsg " Finished" + Catch { Write-Error $_.Exception.Message } + Write-Output " Finished" } } } $LogFileContent = (Get-Content $LogFile) - ## Write the log file output to the console + # Write the log file output to the console If ( $LogFileContent ) { Write-Output $LogFileContent } - ## Delete the log file if it's empty + # Delete the log file if it's empty Else { Remove-Item $LogFile -Force } } -## Return a Powershell version object from a string +# Return a Powershell version object from a string Function Get-Version { param([Parameter(Mandatory=$true)][string]$Version) [int]$Sets = 4 @@ -173,7 +173,7 @@ Function Get-Version { Return [version]$Return.Trim('.') } -## Determines whether a URL is valid +# Determines whether a URL is valid Function IsURLValid { param([Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$URL) Try { @@ -187,7 +187,7 @@ Function IsURLValid { Else { Return $false } } -## Downloads a file from a URL +# Downloads a file from a URL Function Download-File { param( [Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$URL, @@ -196,20 +196,20 @@ Function Download-File { If ( !($File) ) { $File = '{0}{1}' -f (Get-TempPath), (Split-Path $URL -Leaf) } If ( IsURLValid $URL ) { If ( Test-Path $File ) { - LogMsg "Deleting existing file: ""${File}""" + Write-Output "Deleting existing file: ""${File}""" Try { Remove-Item $File -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } - LogMsg "Downloading ""${URL}"" to ""${File}""" + Write-Output "Downloading ""${URL}"" to ""${File}""" Try { (New-Object System.Net.WebClient).DownloadFile($URL,$File) } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } If ( Test-Path "${File}" ) { Return "${File}" } - Else { LogMsg "Downloaded file does not exist at ""${File}""" ; Return $false } + Else { Write-Output "Downloaded file does not exist at ""${File}""" ; Return $false } } - Else { LogMsg "URL is not valid or file cannot be reached: ${URL}" } + Else { Write-Output "URL is not valid or file cannot be reached: ${URL}" } } -## Install a program from a provided path +# Install a program from a provided path Function Install-Program { param( [Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Path, @@ -217,24 +217,24 @@ Function Install-Program { [Parameter(Mandatory=$false)][switch]$Delete = $false ) If ( Test-Path "${Path}" ) { - LogMsg "Running installer: ""${Path}"" ${Arguments}" + Write-Output "Running installer: ""${Path}"" ${Arguments}" Try { If ( $Arguments -eq '' ) { Start-Process "${Path}" -Wait } Else { Start-Process "${Path}" -ArgumentList "${Arguments}" -Wait } } - Catch { LogErr $_.Exception.Message } - LogMsg "Installer finished" + Catch { Write-Error $_.Exception.Message } + Write-Output "Installer finished" If ( $Delete ) { - LogMsg "Deleting installer: ""${Path}""" + Write-Output "Deleting installer: ""${Path}""" Try { Remove-Item -Path "${Path}" -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } - Else { LogMsg "The specified file could not be found: ""${Path}""" } + Else { Write-Output "The specified file could not be found: ""${Path}""" } } -## Compare current Windows version with a supplied version -## The value supplied must be a string and must include at least 1 decimal +# Compare current Windows version with a supplied version +# The value supplied must be a string and must include at least 1 decimal Function IsWindowsVersion { param( [Parameter(Mandatory=$true,ParameterSetName='gt')][string]$gt, @@ -253,8 +253,8 @@ Function IsWindowsVersion { } } -## Compare current Windows build with a supplied version -## The value supplied must be an int +# Compare current Windows build with a supplied version +# The value supplied must be an int Function IsWindowsBuild { param( [Parameter(Mandatory=$true,ParameterSetName='gt')][int]$gt, @@ -273,19 +273,19 @@ Function IsWindowsBuild { } } -## Get the path to the TEMP folder (context dependent) +# Get the path to the TEMP folder (context dependent) Function Get-TempPath { Return [System.IO.Path]::GetTempPath() } -## Determine if the system is 64-bit or not +# Determine if the system is 64-bit or not Function Is64bit { switch ( $(Get-CimInstance -ClassName Win32_OperatingSystem -Property OSArchitecture | Select-Object -ExpandProperty OSArchitecture) ) { '64-bit' { Return $true } '32-bit' { Return $false } } } -## Determine if the Powershell process is 64-bit or not +# Determine if the Powershell process is 64-bit or not Function Is64bitShell { If ( [System.Environment]::Is64BitProcess ) { Return $true } Else { Return $false } } -## Determine if a user is in a built-in role or specified group +# Determine if a user is in a built-in role or specified group Function IsMemberOf { param( [Parameter(Mandatory=$false)] @@ -319,7 +319,7 @@ Function IsMemberOf { Return ([Security.Principal.WindowsPrincipal][System.Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole($Group) } -## Start, stop, restart, or delete a list of services +# Start, stop, restart, or delete a list of services Function Control-Service { param( @@ -366,7 +366,7 @@ Function Control-Service Exit } 'delete' { - ## Delete the service + # Delete the service } 'disable' { $ArgString = $MyInvocation.Line @@ -381,9 +381,9 @@ Function Control-Service ForEach ( $item in $Name ) { $service = Get-Service -Name $item -ErrorAction SilentlyContinue If ( !($service) ) { - LogMsg "Cannot find the service '${item}'" + Write-Output "Cannot find the service '${item}'" If ( $Match ) { - LogMsg "Attempting to match '${item}' to service display names" + Write-Output "Attempting to match '${item}' to service display names" ForEach ( $svc in ((Get-Service | Where-Object { $_.DisplayName -match $item }).Name) ) { Switch ( $verb) { 'start' { Control-Service -Start -Name $svc } @@ -403,7 +403,7 @@ Function Control-Service $displayname = """${fullname}"" (${name})" } If ( $service.Status -ne $statuscondition ) { - LogMsg "${verbing} ${displayname}" + Write-Output "${verbing} ${displayname}" Try { Switch ( $verb) { 'start' { Start-Service -Name $name } @@ -411,13 +411,13 @@ Function Control-Service 'disable' { Set-Service -Name "${name}" -StartupType Disabled } } } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } } } -## Stop a process +# Stop a process Function End-Process { param( @@ -428,9 +428,9 @@ Function End-Process ForEach ( $item in $Name ) { $process = Get-Process -Name $item -ErrorAction SilentlyContinue If ( !($process) ) { - LogMsg "Cannot find the process '${item}'" + Write-Output "Cannot find the process '${item}'" If ( $Match ) { - LogMsg "Attempting to match '${item}' to all running process names" + Write-Output "Attempting to match '${item}' to all running process names" ForEach ( $proc in ((Get-Process | Where-Object { $_.Name -match $item }).Name) ) { If ( $Force ) { End-Process -Name $proc -Force } Else { End-Process -Name $proc } } @@ -439,11 +439,11 @@ Function End-Process Else { $name = $process.Name If ( $Force ) { - LogMsg "Forcefully stopping '${name}' process" + Write-Output "Forcefully stopping '${name}' process" Stop-Process $process -Force -ErrorAction SilentlyContinue } Else { - LogMsg "Attempting to gracefully close '${name}' process" + Write-Output "Attempting to gracefully close '${name}' process" $process.CloseMainWindow() | Out-Null } } @@ -461,9 +461,9 @@ Function Create-Shortcut { ) If ( Test-Path $TargetPath ) { If ( Test-Path $Path ) { - LogMsg "Deleting existing shortcut at ""${Path}""" + Write-Output "Deleting existing shortcut at ""${Path}""" Try { Remove-Item $Path -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } If ( $WorkingDirectory -eq '' ) { $WorkingDirectory = Split-Path $TargetPath -Parent } If ( $Icon -eq '' ) { $Icon = "${TargetPath}, 0" } @@ -474,11 +474,11 @@ Function Create-Shortcut { $Shortcut.IconLocation = $Icon $Shortcut.WorkingDirectory = $WorkingDirectory $Shortcut.TargetPath = $TargetPath - LogMsg "Creating shortcut to ""${TargetPath}"" at ""${Path}""" + Write-Output "Creating shortcut to ""${TargetPath}"" at ""${Path}""" Try { $Shortcut.Save() } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } - Else { LogMsg "Cannot create shortcut because the target path does not exist" } + Else { Write-Output "Cannot create shortcut because the target path does not exist" } } # Function to enable or disable a specified log @@ -490,11 +490,11 @@ Function Toggle-Log { ) Try { $log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration $Name - If ( $Enable ) { LogMsg "Enabing ${Name} event log" ; $log.IsEnabled = $true } - If ( $Disable ) { LogMsg "Disabing ${Name} event log" ; $log.IsEnabled = $false } + If ( $Enable ) { Write-Output "Enabing ${Name} event log" ; $log.IsEnabled = $true } + If ( $Disable ) { Write-Output "Disabing ${Name} event log" ; $log.IsEnabled = $false } $log.SaveChanges() } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } } # Function to install the PSAtera Powershell module @@ -502,14 +502,14 @@ Function Install-PSAteraModule { Try { $module = Get-Module -ListAvailable -Name PSAtera If ( (-not $module) -and (IsAdmin) ) { - LogMsg "Installing PSAtera Powershell module" + Write-Output "Installing PSAtera Powershell module" Install-Module -Name PSAtera -Force } ElseIf ( (-not $module) -and (-not (IsAdmin)) ) { - LogMsg "The PSAtera module needs to be installed, but the current security context is not sufficient to install it" + Write-Output "The PSAtera module needs to be installed, but the current security context is not sufficient to install it" } } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } # Function to install the MSP360 Powershell module @@ -517,15 +517,15 @@ Function Install-MSP360Module { Try { $module = Get-Module -ListAvailable -Name MSP360 If ( (-not $module) -and (IsAdmin) ) { - LogMsg "Installing MSP360 Powershell module" + Write-Output "Installing MSP360 Powershell module" Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://git.io/JUSAA'); Install-MSP360Module } ElseIf ( (-not $module) -and (-not (IsAdmin)) ) { - LogMsg "The MSP360 Powershell module needs to be installed, but the current security context is not sufficient to install it" + Write-Output "The MSP360 Powershell module needs to be installed, but the current security context is not sufficient to install it" } } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } # Function to delete a file @@ -533,10 +533,10 @@ Function Remove-File ([Parameter(ValueFromPipeline=$true)][string]$path) { If ( Test-Path $path ) { If ( !((Get-Item $path) -is [System.IO.DirectoryInfo]) ) { Try { - LogMsg "Delete ""${path}""" + Write-Output "Delete ""${path}""" Remove-Item $path -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } } @@ -549,40 +549,40 @@ Function Zip-Object { ) If ( $(Get-Item $path) -is [System.IO.DirectoryInfo] ) { If ( [string]::IsNullOrEmpty($dest) ) { $dest = '{0}\{1}.zip' -f $(Split-Path -Parent $path),$(Split-Path -Leaf $path) } - LogMsg "Creating zip file of: ${path}" + Write-Output "Creating zip file of: ${path}" Try { Add-Type -Assembly "System.IO.Compression.FileSystem" [IO.Compression.ZipFile]::CreateFromDirectory($path, $dest) } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } If ( Test-Path $dest ) { Return $dest } Else { Return $false } } ElseIf ( $(Get-Item $path) -is [System.IO.FileInfo] ) { $dir = $path.Substring(0, $path.LastIndexOf('.')) Try { - LogMsg "Creating directory: ${path}" + Write-Output "Creating directory: ${path}" New-Item -ItemType Directory -Path $dir -ErrorAction Stop | Out-Null - LogMsg "Moving ""${path}"" into ""${dir}""" + Write-Output "Moving ""${path}"" into ""${dir}""" Move-Item -Path $path -Destination $dir -Force -ErrorAction Stop | Out-Null } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } Zip-Object $dir } - Else { LogMsg "Could not determine the file/folder status: ${path}" } + Else { Write-Output "Could not determine the file/folder status: ${path}" } } # Function to UNZIP a file or directory Function Unzip-Object ([Parameter(ValueFromPipeline=$true)][string]$path) { If ( [System.IO.Path]::GetExtension($path) -eq ".zip" ) { $dest = Split-Path -Parent $path - LogMsg "Extracting ""${path}"" to ""${dest}""" + Write-Output "Extracting ""${path}"" to ""${dest}""" Try { Add-Type -Assembly "System.IO.Compression.FileSystem" [IO.Compression.ZipFile]::ExtractToDirectory($path, $dest) } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } - Else { LogMsg "The path specified is not a zip file: ${path}" } + Else { Write-Output "The path specified is not a zip file: ${path}" } } # Function to get a copy of the LiquidFiles CLI agent @@ -592,14 +592,14 @@ Function Get-LiquidFilesCLI { $zip_path = "${Global:ToolsDirectory}\${zip_filename}" $exe_path = '{0}\{1}.exe' -f $Global:ToolsDirectory,[System.IO.Path]::GetFileNameWithoutExtension($zip_filename) If ( Test-Path $zip_path ) { - LogMsg "Deleting existing zip archive: ${zip_path}" + Write-Output "Deleting existing zip archive: ${zip_path}" Try { Remove-Item -Path $zip_path -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } If ( Test-Path $exe_path ) { - LogMsg "Deleting existing file: ${exe_path}" + Write-Output "Deleting existing file: ${exe_path}" Try { Remove-Item -Path $exe_path -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Download-File -URL $url -File $zip_path | Out-Null Unzip-Object $zip_path @@ -623,35 +623,35 @@ Function Create-LocalUser { [Parameter(Mandatory=$false)][switch]$Hide=$false ) - ## Secure supplied password + # Secure supplied password Try { $SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force ; $Password = $null } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } If ( IsAdmin ) { If ( $(Get-CimInstance -ClassName Win32_OperatingSystem -Property ProductType | Select-Object -ExpandProperty ProductType) -ne "2" ) { If ( $(Get-LocalUser -Name $Username -ErrorAction SilentlyContinue) ) { - LogMsg "Updating user: ${Username}" + Write-Output "Updating user: ${Username}" Try { Set-LocalUser -Name $Username -Password $SecurePassword -FullName $FullName -Description $Description -AccountNeverExpires -PasswordNeverExpires } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } } Else { - LogMsg "Creating user: ${Username}" + Write-Output "Creating user: ${Username}" Try { New-LocalUser -Name $Username -Password $SecurePassword -FullName $FullName -Description $Description -AccountNeverExpires -PasswordNeverExpires } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } } If ( (-not($(Get-LocalGroupMember -Group "Administrators" -Member $Username -ErrorAction SilentlyContinue))) -and $MakeAdmin ) { - LogMsg "Adding ""${Username}"" to local Administrators group" + Write-Output "Adding ""${Username}"" to local Administrators group" Try { Add-LocalGroupMember -Name "Administrators" -Member $(Get-LocalUser -Name $Username) } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } } } - Else { LogMsg "Cannot create or modify local accounts on a domain controller" } + Else { Write-Output "Cannot create or modify local accounts on a domain controller" } } - Else { LogMsg "Cannot create or modify a local account without administrative privileges" } + Else { Write-Output "Cannot create or modify a local account without administrative privileges" } If ( $Hide ) { # TODO: Hide account from logon screen @@ -669,9 +669,9 @@ Function Stop-MemoryHog ([string]$AppName,[int]$MemoryLimit) { $MemoryUsed = (Get-MemoryUsage -AppName $AppName) If ( $MemoryUsed -gt $MemoryLimit ) { $MemoryDifference = $MemoryUsed - $MemoryLimit - LogMsg "Killing ""${AppName}"" for using ${MemoryDifference}MB over the limit of ${MemoryLimit}MB" + Write-Output "Killing ""${AppName}"" for using ${MemoryDifference}MB over the limit of ${MemoryLimit}MB" Try { Get-Process -Name $AppName -ErrorAction SilentlyContinue | Stop-Process -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } @@ -723,7 +723,7 @@ Function Get-FileSizes { # Output to log file $logstr = "${prefix}" + $($FileSizes | Format-List | Out-String) - LogMsg $logstr + Write-Output $logstr } # Function to write text to a file in UTF8 encoding without BOM @@ -734,7 +734,7 @@ Function WriteToFile_UTF8NoBOM { ) $UTF8NoBOM = New-Object System.Text.UTF8Encoding $false Try { [IO.File]::WriteAllText($FilePath, $CONFIG, $UTF8NoBOM) } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } # Function to enumerate all user profile folders @@ -813,7 +813,7 @@ Function Uninstall-MSI ([Parameter(ValueFromPipeline=$true)][string[]]$APP_NAMES $UNINSTALL_KEYS += Get-ChildItem -Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall -ErrorAction SilentlyContinue # Exit if we can't find any software at all - If ( $UNINSTALL_KEYS.Length -eq 0 ) { LogErr "Attempted to uninstall ${APP_NAMES} but could not find any installed apps in the Windows Registry" ; Return } + If ( $UNINSTALL_KEYS.Length -eq 0 ) { Write-Error "Attempted to uninstall ${APP_NAMES} but could not find any installed apps in the Windows Registry" ; Return } # Array to store custom objects about each installed MSI app $INSTALLED_APPS = @() @@ -862,15 +862,15 @@ Function Uninstall-MSI ([Parameter(ValueFromPipeline=$true)][string[]]$APP_NAMES # Print out uninstall string for unsupported apps If ( $installed_app.UninstallSupported -eq $false ) { - LogMsg "Cannot uninstall ""${DisplayName}""`n UninstallString: ${UninstallString}" + Write-Output "Cannot uninstall ""${DisplayName}""`n UninstallString: ${UninstallString}" Continue } # Uninstall the app - LogMsg "Uninstalling ""${DisplayName}"" with product code: ${ProductCode}" + Write-Output "Uninstalling ""${DisplayName}"" with product code: ${ProductCode}" $arguments = '/X{' + $ProductCode + '} /qn /norestart' Try { Start-Process -FilePath "msiexec.exe" -ArgumentList $arguments -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } } @@ -881,7 +881,7 @@ Function Restart-EndpointOnUptime ([timespan]$MaxUptime) { # Get the length of time the endpoint has been running without restart Try { $LastBootTime = (Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction Stop).LastBootUpTime } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } # Get the difference between the endpoint uptime and the current time $Delta = New-TimeSpan -Start $LastBootTime -End $(Get-Date) @@ -891,7 +891,7 @@ Function Restart-EndpointOnUptime ([timespan]$MaxUptime) { # Reboot the endpoint Try { Restart-Computer -Force -ErrorAction Stop } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Setup-MSPDirectories diff --git a/Uninstall-AdobeFlash.ps1 b/Uninstall-AdobeFlash.ps1 index c54dcc8..f4b9250 100644 --- a/Uninstall-AdobeFlash.ps1 +++ b/Uninstall-AdobeFlash.ps1 @@ -6,13 +6,13 @@ If ( IsAdmin ) { $RegKey = 'HKLM:SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player NPAPI' } If ( $RegKey ) { - LogMsg "Found uninstall string: ${UninstallString}" + Write-Output "Found uninstall string: ${UninstallString}" $UninstallString = (Get-ItemProperty -Path $RegKey).UninstallString $UninstallProgram = $UninstallString -replace ' -maintain plugin', '' - LogMsg "Running: ""${UninstallProgram}"" -uninstall" + Write-Output "Running: ""${UninstallProgram}"" -uninstall" Try { Start-Process "${UninstallProgram}" -ArgumentList "-uninstall" -Wait } Catch { LogErr $_.Exception.Message } } - Else { LogMsg "Adobe Flash Player is not installed" } + Else { Write-Output "Adobe Flash Player is not installed" } } -Else { LogMsg "Must have administrative privileges to uninstall Adobe Flash" } \ No newline at end of file +Else { Write-Output "Must have administrative privileges to uninstall Adobe Flash" } \ No newline at end of file diff --git a/Uninstall-AteraAgent.ps1 b/Uninstall-AteraAgent.ps1 index eb6b6ff..d5d454a 100644 --- a/Uninstall-AteraAgent.ps1 +++ b/Uninstall-AteraAgent.ps1 @@ -8,7 +8,7 @@ Function Get-UninstallCodes ([string]$DisplayName) { If ( $(Get-ItemProperty -Path $_.PSPath -Name 'DisplayName' -ErrorAction SilentlyContinue) -and ($(Get-ItemPropertyValue -Path $_.PSPath -Name 'DisplayName' -ErrorAction SilentlyContinue) -eq $DisplayName) ) { $str = (Get-ItemPropertyValue -Path $_.PSPath -Name 'UninstallString') $code = $str.Substring(($str.Length - 37),36) - LogMsg " - ${code}" + Write-Output " - ${code}" $UninstallCodes.Add($code) | Out-Null } } @@ -19,7 +19,7 @@ Function Get-ProductKeys ([string]$ProductName) { Get-ChildItem -Path 'HKCR:Installer\Products' | ForEach-Object { If ( $(Get-ItemProperty -Path $_.PSPath -Name 'ProductName' -ErrorAction SilentlyContinue) -and ($(Get-ItemPropertyValue -Path $_.PSPath -Name 'ProductName' -ErrorAction SilentlyContinue) -eq $ProductName) ) { $prod = $_.PSPath.Substring($_.PSPath.Length - 32) - LogMsg " - ${prod}" + Write-Output " - ${prod}" $ProductKeys.Add($prod) | Out-Null } } @@ -28,30 +28,30 @@ Function Get-ProductKeys ([string]$ProductName) { Function Get-ServiceStatus ([string]$Name) { (Get-Service -Name $Name -ErrorAction SilentlyContinue).Status } Function Stop-RunningService ([string]$Name) { - If ( $(Get-ServiceStatus -Name $Name) -eq "Running" ) { LogMsg "Stopping : ${Name} service" ; Stop-Service -Name $Name -Force } + If ( $(Get-ServiceStatus -Name $Name) -eq "Running" ) { Write-Output "Stopping : ${Name} service" ; Stop-Service -Name $Name -Force } } Function Remove-StoppedService ([string]$Name) { $s = (Get-ServiceStatus -Name $Name) If ( $s ) { If ( $s -eq "Stopped" ) { - LogMsg "Deleting : ${Name} service" + Write-Output "Deleting : ${Name} service" Start-Process "sc.exe" -ArgumentList "delete ${Name}" -Wait } - } Else { LogMsg "Not Found: ${Name} service" } + } Else { Write-Output "Not Found: ${Name} service" } } Function Stop-RunningProcess ([string]$Name) { $p = (Get-Process -Name $_ -ErrorAction SilentlyContinue) - If ( $p ) { LogMsg "Stopping : ${Name}.exe" ; $p | Stop-Process -Force } - Else { LogMsg "Not Found: ${Name}.exe is not running"} + If ( $p ) { Write-Output "Stopping : ${Name}.exe" ; $p | Stop-Process -Force } + Else { Write-Output "Not Found: ${Name}.exe is not running"} } Function Remove-Path ([string]$Path) { If ( Test-Path $Path ) { - LogMsg "Deleting : ${Path}" + Write-Output "Deleting : ${Path}" Remove-Item $Path -Recurse -Force - } Else { LogMsg "Not Found: ${Path}" } + } Else { Write-Output "Not Found: ${Path}" } } Function Get-AllExeFiles ([string]$Path) { @@ -60,39 +60,39 @@ Function Get-AllExeFiles ([string]$Path) { } } -LogMsg "Uninstalling Atera agent" +Write-Output "Uninstalling Atera agent" -LogMsg "Mounting HKEY_CLASSES_ROOT registry hive" +Write-Output "Mounting HKEY_CLASSES_ROOT registry hive" New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null -LogMsg "Getting MSI package codes from the uninstall key" +Write-Output "Getting MSI package codes from the uninstall key" $UninstallCodes = New-Object System.Collections.ArrayList 'AteraAgent' | ForEach-Object { Get-UninstallCodes -DisplayName $_ } -LogMsg "Getting product keys from the list of installed products" +Write-Output "Getting product keys from the list of installed products" $ProductKeys = New-Object System.Collections.ArrayList 'AteraAgent' | ForEach-Object { Get-ProductKeys -ProductName $_ } -LogMsg "Directories that we may need to delete" +Write-Output "Directories that we may need to delete" $Directories = @("${Env:ProgramFiles}\ATERA Networks") -$Directories | ForEach-Object { LogMsg " - ${_}" } +$Directories | ForEach-Object { Write-Output " - ${_}" } -LogMsg "Processes that we may need to terminate" +Write-Output "Processes that we may need to terminate" $ExeFiles = New-Object System.Collections.ArrayList $Directories | ForEach-Object { Get-AllExeFiles -Path $_ } $ExeFiles.Add('reg') | Out-Null -$ExeFiles | ForEach-Object { LogMsg " - ${_}.exe" } +$ExeFiles | ForEach-Object { Write-Output " - ${_}.exe" } -LogMsg "Windows services that we may need to stop and/or delete" +Write-Output "Windows services that we may need to stop and/or delete" $ServiceList = @('AteraAgent') -$ServiceList | ForEach-Object { LogMsg " - ${_}" } +$ServiceList | ForEach-Object { Write-Output " - ${_}" } -LogMsg "Windows Registry keys we may need to delete" +Write-Output "Windows Registry keys we may need to delete" $RegistryKeys = @('HKLM:SOFTWARE\ATERA Networks') -$RegistryKeys | ForEach-Object { LogMsg " - ${_}" } +$RegistryKeys | ForEach-Object { Write-Output " - ${_}" } # Uninstall each MSI package code in $UninstallCodes -$UninstallCodes | ForEach-Object { LogMsg "Uninstall: ${_}" ; Start-Process "msiexec.exe" -ArgumentList "/X{${_}} /qn" -Wait } +$UninstallCodes | ForEach-Object { Write-Output "Uninstall: ${_}" ; Start-Process "msiexec.exe" -ArgumentList "/X{${_}} /qn" -Wait } # Stop services if they're still running $ServiceList | ForEach-Object { Stop-RunningService -Name $_ } @@ -112,10 +112,10 @@ $RegistryKeys | ForEach-Object { Remove-Path -Path $_ } # Delete remaining directories $Directories | ForEach-Object { Remove-Path -Path $_ } -LogMsg "Unmount HKEY_CLASSES_ROOT registry hive" +Write-Output "Unmount HKEY_CLASSES_ROOT registry hive" Remove-PSDrive -Name HKCR -LogMsg "Finished uninstalling Atera Agent" +Write-Output "Finished uninstalling Atera Agent" # Delete this script Remove-Item $MyInvocation.MyCommand.Path -Force \ No newline at end of file diff --git a/Uninstall-AutodeskDesktopApp.ps1 b/Uninstall-AutodeskDesktopApp.ps1 index 01872fd..e0355fb 100644 --- a/Uninstall-AutodeskDesktopApp.ps1 +++ b/Uninstall-AutodeskDesktopApp.ps1 @@ -6,38 +6,38 @@ If ( $PATH ) $SVC = Get-Service -Name "AdAppMgrSvc" If ( $SVC.Status -ne "Stopped" ) { - LogMsg "Stopping AdAppMgrSvc service" + Write-Output "Stopping AdAppMgrSvc service" Try { $SVC | Stop-Service -Force } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } } - LogMsg "Stopping processes" + Write-Output "Stopping processes" Try { Get-Process | Where { $_.Name -like "AdAppMgr" } | Stop-Process -Force Get-Process | Where { $_.Name -like "AutodeskDesktopApp" } | Stop-Process -Force } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } - LogMsg "Uninstalling Autodesk Desktop App" + Write-Output "Uninstalling Autodesk Desktop App" Try { Start-Process -FilePath $PATH -ArgumentList '--mode unattended' -Wait } - Catch { LogMsg $_.Exception.Message } + Catch { Write-Output $_.Exception.Message } If ( Test-Path "HKLM:\SOFTWARE\Wow6432Node\Autodesk\Autodesk Application Manager" ) { - LogMsg "Removing: ""HKLM:\SOFTWARE\Wow6432Node\Autodesk\Autodesk Application Manager""" + Write-Output "Removing: ""HKLM:\SOFTWARE\Wow6432Node\Autodesk\Autodesk Application Manager""" Remove-Item "HKLM:\SOFTWARE\Wow6432Node\Autodesk\Autodesk Application Manager" -Force -ErrorAction SilentlyContinue } If ( Test-Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Autodesk Desktop App" ) { - LogMsg "Removing: ""HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Autodesk Desktop App""" + Write-Output "Removing: ""HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Autodesk Desktop App""" Remove-Item "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Autodesk Desktop App" -Force -ErrorAction SilentlyContinue } If ( Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AdAppMgrSvc.exe" ) { - LogMsg "Removing: ""HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AdAppMgrSvc.exe""" + Write-Output "Removing: ""HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AdAppMgrSvc.exe""" Remove-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AdAppMgrSvc.exe" -Force -ErrorAction SilentlyContinue } If ( Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AutodeskDesktopApp.exe" ) { - LogMsg "Removing: ""HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AutodeskDesktopApp.exe""" + Write-Output "Removing: ""HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AutodeskDesktopApp.exe""" Remove-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AutodeskDesktopApp.exe" -Force -ErrorAction SilentlyContinue } } -Else { LogMsg "Autodesk Desktop App is not installed" } \ No newline at end of file +Else { Write-Output "Autodesk Desktop App is not installed" } \ No newline at end of file diff --git a/Uninstall-EmberkomCloudBackup.ps1 b/Uninstall-EmberkomCloudBackup.ps1 index 60bdacb..cdb7ee2 100644 --- a/Uninstall-EmberkomCloudBackup.ps1 +++ b/Uninstall-EmberkomCloudBackup.ps1 @@ -3,6 +3,6 @@ Install-MSP360Module Import-Module -Name MSP360 ## Uninstall the agent -LogMsg "Uninstalling Emberkom Cloud Backup agent" +Write-Output "Uninstalling Emberkom Cloud Backup agent" Try { Remove-MBSAgent -RemoveSettings -Force } Catch { LogErr $_.Exception.Message } diff --git a/Uninstall-MicrosoftOffice.ps1 b/Uninstall-MicrosoftOffice.ps1 index 0c2629b..7892d4f 100644 --- a/Uninstall-MicrosoftOffice.ps1 +++ b/Uninstall-MicrosoftOffice.ps1 @@ -26,12 +26,12 @@ $UninstallScript = Download-File -URL $UninstallScriptURL $ScriptArgs = "/ALL /QUIET /NOCANCEL" # Run the script -LogMsg "Uninstalling all Click2Run versions of Office" +Write-Output "Uninstalling all Click2Run versions of Office" Try { Start-Process "cscript.exe" -ArgumentList "//nologo ""${UninstallScript}"" ${ScriptArgs}" -Wait } Catch { LogErr $_.Exception.Message } # Delete the downloaded script If ( Test-Path $UninstallScript ) { - LogMsg "Deleting downloaded script: ""${UninstallScript}""" + Write-Output "Deleting downloaded script: ""${UninstallScript}""" Remove-Item -Path $UninstallScript -Force -ErrorAction SilentlyContinue } \ No newline at end of file diff --git a/Uninstall-NCentralComponents.ps1 b/Uninstall-NCentralComponents.ps1 index 2cf0c80..bc3d1f9 100644 --- a/Uninstall-NCentralComponents.ps1 +++ b/Uninstall-NCentralComponents.ps1 @@ -1,21 +1,21 @@  ## Remove N-Central Patch Management Service Controller If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\PME\unins000.exe" ) { - LogMsg "Uninstalling N-Central Patch Management Service Controller" + Write-Output "Uninstalling N-Central Patch Management Service Controller" Try { Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\PME\unins000.exe" -ArgumentList "/SILENT" -Wait } Catch { LogErr $_.Exception.Message } } ## Remove N-Central File Cache Service Agent If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\FileCacheServiceAgent\unins000.exe" ) { - LogMsg "Uninstalling N-Central File Cache Service Agent" + Write-Output "Uninstalling N-Central File Cache Service Agent" Try { Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\FileCacheServiceAgent\unins000.exe" -ArgumentList "/SILENT" -Wait } Catch { LogErr $_.Exception.Message } } ## Remove N-Central Request Handler Agent If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\RequestHandlerAgent\unins000.exe" ) { - LogMsg "Uninstalling N-Central Request Handler Agent" + Write-Output "Uninstalling N-Central Request Handler Agent" Try { Start-Process "${Env:ProgramFiles(x86)}\MspPlatform\RequestHandlerAgent\unins000.exe" -ArgumentList "/SILENT" -Wait } Catch { LogErr $_.Exception.Message } } @@ -23,14 +23,14 @@ If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\RequestHandlerAgent\unins00 ## Remove Windows Software Probe If ( Test-Path "${ProgramFiles(x86)}\N-able Technologies\Windows Software Probe\" ) { $ProductCode = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\N-able Technologies\Windows Software Probe").ProductCode - LogMsg "Uninstalling Windows Software Probe" + Write-Output "Uninstalling Windows Software Probe" Try { Start-Process "msiexec.exe" -ArgumentList "/X {${ProductCode}} /qn" -Wait } Catch { LogErr $_.Exception.Message } } ## Remove Windows Agent If ( Test-Path "${ProgramFiles(x86)}\N-able Technologies\Windows Agent\" ) { - LogMsg "Uninstalling N-Central Windows Agent" + Write-Output "Uninstalling N-Central Windows Agent" Try { Start-Process "msiexec.exe" -ArgumentList "/X{F5873D07-85EE-4010-A461-B60989884B1C} /qn" -Wait } Catch { LogErr $_.Exception.Message } } @@ -40,7 +40,7 @@ $ServiceName = "NablePatchRepositoryService" $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName - LogMsg "Deleting the service: ""${ServiceName}""" + Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } Catch { LogErr $_.Exception.Message } } @@ -50,7 +50,7 @@ $ServiceName = "Windows Software Probe Maintenance Service" $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName - LogMsg "Deleting the service: ""${ServiceName}""" + Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } Catch { LogErr $_.Exception.Message } } @@ -60,7 +60,7 @@ $ServiceName = "Windows Software Probe Syslog Service" $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName - LogMsg "Deleting the service: ""${ServiceName}""" + Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } Catch { LogErr $_.Exception.Message } } @@ -70,7 +70,7 @@ $ServiceName = "Windows Software Probe Service" $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName - LogMsg "Deleting the service: ""${ServiceName}""" + Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } Catch { LogErr $_.Exception.Message } } @@ -80,7 +80,7 @@ $ServiceName = "Windows Agent Maintenance Service" $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName - LogMsg "Deleting the service: ""${ServiceName}""" + Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } Catch { LogErr $_.Exception.Message } } @@ -90,33 +90,33 @@ $ServiceName = "Windows Agent Service" $Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName - LogMsg "Deleting the service: ""${ServiceName}""" + Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } Catch { LogErr $_.Exception.Message } } ## Remove "MspPlatform" directory If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform" ) { - LogMsg "Forcefully removing ""${Env:ProgramFiles(x86)}\MspPlatform""" + Write-Output "Forcefully removing ""${Env:ProgramFiles(x86)}\MspPlatform""" Try { Remove-Item "${Env:ProgramFiles(x86)}\MspPlatform" -Recurse -Force } Catch { LogErr $_.Exception.Message } } ## Remove "N-able Technologies" directory If ( Test-Path "${Env:ProgramFiles(x86)}\N-able Technologies" ) { - LogMsg "Forcefully removing ""${Env:ProgramFiles(x86)}\N-able Technologies""" + Write-Output "Forcefully removing ""${Env:ProgramFiles(x86)}\N-able Technologies""" Try { Remove-Item "${Env:ProgramFiles(x86)}\N-able Technologies" -Recurse -Force } Catch { LogErr $_.Exception.Message } } ## Remove "N-able Technologies" registry key If ( Test-Path "HKLM:SOFTWARE\Wow6432Node\N-able Technologies" ) { - LogMsg "Forcefully removing ""HKLM:SOFTWARE\Wow6432Node\N-able Technologies""" + Write-Output "Forcefully removing ""HKLM:SOFTWARE\Wow6432Node\N-able Technologies""" Try { Remove-Item "HKLM:SOFTWARE\Wow6432Node\N-able Technologies" -Recurse -Force } Catch { LogErr $_.Exception.Message } } If ( Test-Path "HKLM:SOFTWARE\N-able Technologies" ) { - LogMsg "Forcefully removing ""HKLM:SOFTWARE\N-able Technologies""" + Write-Output "Forcefully removing ""HKLM:SOFTWARE\N-able Technologies""" Try { Remove-Item "HKLM:SOFTWARE\N-able Technologies" -Recurse -Force } Catch { LogErr $_.Exception.Message } } diff --git a/Uninstall-UnwantedDefaultApps.ps1 b/Uninstall-UnwantedDefaultApps.ps1 index 491728b..76c942a 100644 --- a/Uninstall-UnwantedDefaultApps.ps1 +++ b/Uninstall-UnwantedDefaultApps.ps1 @@ -1,5 +1,5 @@ # Make sure this script runs as admin -#If ( IsAdmin -eq $false ) { LogMsg "This script can only be run as admin" ; Exit } +#If ( IsAdmin -eq $false ) { Write-Output "This script can only be run as admin" ; Exit } # This is the list of Windows 10 AppX app names that we'll try to uninstall $AppList = @( @@ -59,19 +59,19 @@ If ( IsWindowsBuild -ge 9200 ) # If the package exists, uninstall it If ($PackageFullName) { - LogMsg “Removing package: ${PackageFullName}” + Write-Output “Removing package: ${PackageFullName}” Try { Remove-AppxPackage -Package $PackageFullName } Catch { LogErr $_.Exception.Message } } # If the provisioned package exists, uninstall it If ($ProPackageFullName) { - LogMsg “Removing provisioned package: ${ProPackageFullName}” + Write-Output “Removing provisioned package: ${ProPackageFullName}” Try { Remove-AppxProvisionedPackage -PackageName $ProPackageFullName -Online -AllUsers } Catch { LogErr $_.Exception.Message } } } -} Else { LogMsg "Cannot remove Appx packages because this endpoint is not running Windows 8 or higher" } +} Else { Write-Output "Cannot remove Appx packages because this endpoint is not running Windows 8 or higher" } # Uninstall unwanted Dell apps 'Dell*SupportAssist*', 'Dell Digital Delivery*' | Uninstall-MSI diff --git a/Update-Wireguard.ps1 b/Update-Wireguard.ps1 index 0575409..75cea2d 100644 --- a/Update-Wireguard.ps1 +++ b/Update-Wireguard.ps1 @@ -11,11 +11,11 @@ If (IsAdmin) { ## If the path to wireguard.exe is found, update the app If ( -not [string]::IsNullOrEmpty($PATH) ) { - LogMsg "Updating Wireguard" + Write-Output "Updating Wireguard" Try { Start-Process $PATH -ArgumentList "/update" -Wait } Catch { LogErr $_.Exception.Message } - LogMsg "Finished updating Wireguard" + Write-Output "Finished updating Wireguard" } } -Else { LogMsg "You must be a local administrator to update Wireguard" } \ No newline at end of file +Else { Write-Output "You must be a local administrator to update Wireguard" } \ No newline at end of file diff --git a/Upload-Data.ps1 b/Upload-Data.ps1 index ff5337f..47d0751 100644 --- a/Upload-Data.ps1 +++ b/Upload-Data.ps1 @@ -23,7 +23,7 @@ If ( $LFCLI ) { $Message = "" If ( Test-Path $FileToUpload ) { - LogMsg "Uploading ""${FileToUpload}""" + Write-Output "Uploading ""${FileToUpload}""" If ( $DeleteAfterUpload ) { Try { Start-Process "${LFCLI}" -ArgumentList "filedrop /url:${FiledropURL} /from:""${From}"" /subject:""${Subject}"" /msg:""${Message}"" /c:n /deleteAfterUpload /f:""${FileToUpload}""" -Wait } @@ -34,6 +34,6 @@ If ( $LFCLI ) { Catch { LogErr $_.Exception.Message } } } - Else { LogMsg "The specified file does not exist: ""${FileToUpload}""" } + Else { Write-Output "The specified file does not exist: ""${FileToUpload}""" } } -Else { LogMsg "Could not upload any data because the LiquidFiles CLI tool was not found" } +Else { Write-Output "Could not upload any data because the LiquidFiles CLI tool was not found" }