diff --git a/Cleanup-SystemPath.ps1 b/Cleanup-SystemPath.ps1 index 626890f..00c53a4 100644 --- a/Cleanup-SystemPath.ps1 +++ b/Cleanup-SystemPath.ps1 @@ -24,13 +24,13 @@ Write-Output "Removed Paths:`n`r${REMOVE_PATH}" Try { Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $NEW_PATH } Catch { - LogErr $_.Exception.Message - LogErr "Failed to cleanup system path, using original values" + Write-Error $_.Exception.Message + Write-Error "Failed to cleanup system path, using original values" Try { Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $CURRENT_PATH } Catch { - LogErr $_.Exception.Message - LogErr "This is not good... !! DO NOT RESTART UNTIL SYSTEM PATH IS FIXED !!" + Write-Error $_.Exception.Message + Write-Error "This is not good... !! DO NOT RESTART UNTIL SYSTEM PATH IS FIXED !!" Exit } } \ No newline at end of file diff --git a/Cleanup-SystemTempFiles.ps1 b/Cleanup-SystemTempFiles.ps1 index ee1de98..cb307c8 100644 --- a/Cleanup-SystemTempFiles.ps1 +++ b/Cleanup-SystemTempFiles.ps1 @@ -64,7 +64,7 @@ ForEach($file in $RecycleBin.Items()) { If ( Test-Path "${Env:SystemDrive}\hiberfil.sys" ) { Write-Output "Turning off system hibernation" Try { Start-Process "powercfg" -ArgumentList "-h off" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } # Remove PDCRevocation dump files @@ -81,7 +81,7 @@ If ( Test-Path "${Env:ProgramData}\Genetec\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 } + Catch { Write-Error $_.Exception.Message } } } @@ -101,7 +101,7 @@ If ( Test-Path $ESDB ) { Write-Output " - Starting Windows Search Service" Start-Process "net.exe" -ArgumentList "start wsearch" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } @@ -113,7 +113,7 @@ If ( Test-Path $ADSKInst ) { $path = $folder.FullName Write-Output "Deleting Autodesk installer directory: ""${path}""" Try { Remove-Item $folder -Force -Recurse -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } @@ -136,7 +136,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { Write-Output "Deleting AutoCAD temp files" ForEach ( $tempfile in $AutoCADTempFiles ) { Try { Remove-Item $tempfile -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } } @@ -171,7 +171,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # ForEach ( $path in $IPSW ) { # Write-Output " - Deleting: ""${path}""" # Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } - # Catch { LogErr $_.Exception.Message } + # Catch { Write-Error $_.Exception.Message } # } # } @@ -180,7 +180,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # ForEach ( $path in $IPA ) { # Write-Output " - Deleting: ""${path}""" # Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } - # Catch { LogErr $_.Exception.Message } + # Catch { Write-Error $_.Exception.Message } # } # } # } @@ -193,7 +193,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { $path = $oldDownloadedApp.FullName Write-Output " - Deleting: ""${path}""" Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } @@ -225,7 +225,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # Delete the duplicate file Write-Output "Deleting duplicate download: ""${ToDelete}""" Try { Remove-Item -Path $ToDelete -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } } @@ -240,7 +240,7 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { $path = $file.FullName Write-Output "Deleting: ""${path}""" Try { Remove-Item -Path $path -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } } @@ -252,4 +252,4 @@ ForEach ( $userProfile in $(EnumUserProfiles) ) { # Start-Process "cleanmgr.exe" -ArgumentList "/VERYLOWDISK" # Write-Output " - Finished" #} -#Catch { LogErr $_.Exception.Message } \ No newline at end of file +#Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Disable-TabletMode.ps1 b/Disable-TabletMode.ps1 index 7b1c212..138566f 100644 --- a/Disable-TabletMode.ps1 +++ b/Disable-TabletMode.ps1 @@ -9,6 +9,6 @@ If ( IsWindowsVersion -ge '6.3' ) Set-ItemProperty $RegKey -Name 'TabletMode' -Value 0 Set-ItemProperty $RegKey -Name 'SignInMode' -Value 1 } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } 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 f9e4007..984f4b0 100644 --- a/Fix-AteraAgent.ps1 +++ b/Fix-AteraAgent.ps1 @@ -11,7 +11,7 @@ Stop-Service -Name 'AteraAgent' -Force If ( Test-Path $FolderNewName ) { Write-Output "Deleting previously renamed folder: ${FolderNewName}" Try { Remove-Item $FolderNewName -Recurse -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Write-Output "Stopping AgentPackageMonitoring process" @@ -19,7 +19,7 @@ Get-Process -Name "AgentPackageMonitoring" -ErrorAction SilentlyContinue | Stop- Write-Output "Renaming ${FolderToRename}" Try { Rename-Item $FolderToRename $FolderNewName -Force } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } 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 f806bd4..c575e18 100644 --- a/Fix-AutodeskProductLicensing.ps1 +++ b/Fix-AutodeskProductLicensing.ps1 @@ -14,17 +14,17 @@ $ALST = "${WorkingDir}\AdskLicensingSupportTool.exe" If ( Test-Path $ALST ) { Write-Output "Resetting all Autodesk product licenses to named-user licenses" Try { Start-Process $ALST -ArgumentList '-r ALL:User' -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } If ( Test-Path $LicensingSupportTool ) { Write-Output "Deleting ""${LicensingSupportTool}""" Try { Remove-Item $LicensingSupportTool -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } If ( Test-Path $WorkingDir ) { Write-Output "Deleting ""${WorkingDir}""" Try { Remove-Item $WorkingDir -Force -Recurse -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } \ No newline at end of file diff --git a/Fix-ClearOutlookAutoCompleteCache.ps1 b/Fix-ClearOutlookAutoCompleteCache.ps1 index dc8ab77..e746850 100644 --- a/Fix-ClearOutlookAutoCompleteCache.ps1 +++ b/Fix-ClearOutlookAutoCompleteCache.ps1 @@ -1,3 +1,3 @@ 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 +Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Fix-ClearQuickAccess.ps1 b/Fix-ClearQuickAccess.ps1 index e7268ac..0c2a78b 100644 --- a/Fix-ClearQuickAccess.ps1 +++ b/Fix-ClearQuickAccess.ps1 @@ -8,11 +8,11 @@ If ( IsWindowsVersion -ge "10.0" ) { If ( Test-Path $FILE ) { Write-Output "Clearing Quick Access links" Try { Remove-Item $FILE -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ElseIf ( Test-Path $FILEDIR ) { 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 } + Catch { Write-Error $_.Exception.Message } } Else { Write-Output "Quick Access lists cannot be found!" } diff --git a/Fix-EmberkomCloudBackupProductEdition.ps1 b/Fix-EmberkomCloudBackupProductEdition.ps1 index 5258924..3487fb8 100644 --- a/Fix-EmberkomCloudBackupProductEdition.ps1 +++ b/Fix-EmberkomCloudBackupProductEdition.ps1 @@ -19,13 +19,13 @@ Import-Module -Name MSP360 # Write-Output "Adding backup user account: ${MSP360Username}" # Add-MBSUserAccount -User $MSP360Username -Password $MSP360Password #} -#Catch { LogErr $_.Exception.Message } +#Catch { Write-Error $_.Exception.Message } # Set the agent edition # Note: the product edition must be set *after* the user is added Write-Output "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition""" Try { Set-MBSAgentSetting -Edition $AgentEdition -Verbose } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } # Delete the desktop icon "${Env:PUBLIC}\Desktop\Emberkom Backup.LNK", diff --git a/Fix-EnableGPUScheduling.ps1 b/Fix-EnableGPUScheduling.ps1 index 571362f..3241688 100644 --- a/Fix-EnableGPUScheduling.ps1 +++ b/Fix-EnableGPUScheduling.ps1 @@ -34,7 +34,7 @@ If ( $HardwareGPUSchedulingEnabled -eq $false ) { New-ItemProperty -Path $key -Name $name -PropertyType DWord -Value 2 -Force -ErrorAction Stop Write-Output "A restart is required before this change will take effect" } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { 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 c3429a2..9d7f2f2 100644 --- a/Fix-EnableSystemRestore.ps1 +++ b/Fix-EnableSystemRestore.ps1 @@ -1,4 +1,4 @@ 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 +Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Fix-GroupPolicyUpdate.ps1 b/Fix-GroupPolicyUpdate.ps1 index 2882552..c2e778a 100644 --- a/Fix-GroupPolicyUpdate.ps1 +++ b/Fix-GroupPolicyUpdate.ps1 @@ -1,2 +1,2 @@ Try { Start-Process "gpupdate" -ArgumentList '/force' -Wait } -Catch { LogErr $_.Exception.Message } \ No newline at end of file +Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Fix-MicrosoftTeams.ps1 b/Fix-MicrosoftTeams.ps1 index bcbcc1d..cd45230 100644 --- a/Fix-MicrosoftTeams.ps1 +++ b/Fix-MicrosoftTeams.ps1 @@ -7,7 +7,7 @@ If ( Test-Path "${Env:LocalAppData}\Microsoft\Teams\Update.exe" ) { If ( $ProcessList ) { Write-Output "Stopping Microsoft Teams" Try { $ProcessStopped = $true ; $ProcessList | Stop-Process -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { $ProcessStopped = $false } # Remove all cached content @@ -15,13 +15,13 @@ If ( Test-Path "${Env:LocalAppData}\Microsoft\Teams\Update.exe" ) { If ( Test-Path $CacheDir ) { Write-Output "Removing all cached data for Microsoft Teams" Try { Remove-Item $CacheDir -Recurse -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } 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 ) { Write-Output "Starting Microsoft Teams" Try { Start-Process "${Env:LocalAppData}\Microsoft\Teams\Update.exe" -ArgumentList "--processStart ""Teams.exe""" } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } 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 45f045b..b42ee8b 100644 --- a/Fix-OfficeModernAuth.ps1 +++ b/Fix-OfficeModernAuth.ps1 @@ -3,6 +3,6 @@ $REG_PROP = 'AlwaysUseMSOAuthForAutoDiscover' If ( !((Get-ItemProperty -Path $REG_PATH -Name $REG_PROP -ErrorAction SilentlyContinue).$REG_PROP) ) { 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 } + Catch { Write-Error $_.Exception.Message } } Else { Write-Output "The registry path already exists: ""${REG_PATH}\${REG_PROP}""" } diff --git a/Fix-SystemPrintQueue.ps1 b/Fix-SystemPrintQueue.ps1 index 86ca7dc..b11ebd3 100644 --- a/Fix-SystemPrintQueue.ps1 +++ b/Fix-SystemPrintQueue.ps1 @@ -9,7 +9,7 @@ If (! ($(Get-Service -Name 'spooler').StartType -eq "Disabled") ) { ## Delete all print jobs 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 } + Catch { Write-Error $_.Exception.Message } ## Start the spooler service Control-Service -Start -Name $SERVICE diff --git a/Fix-WindowsScriptingComponents.ps1 b/Fix-WindowsScriptingComponents.ps1 index ac7b8f0..8cb7c2f 100644 --- a/Fix-WindowsScriptingComponents.ps1 +++ b/Fix-WindowsScriptingComponents.ps1 @@ -24,7 +24,7 @@ ForEach ($dll in $DLL_FILES) If ( $dll -Match "syswow64" ) { $REGSVR32 = "${Env:WINDIR}\syswow64\regsvr32" } Else { $REGSVR32 = "regsvr32" } Write-Output "Unregister: ${dll}" Try { Start-Process "${REGSVR32}" -ArgumentList "/u /s ${dll}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } @@ -37,6 +37,6 @@ ForEach ($dll in $DLL_FILES) { $REGSVR32 = "${Env:WINDIR}\syswow64\regsvr32" } Else { $REGSVR32 = "regsvr32" } Write-Output "Register: ${dll}" Try { Start-Process "${REGSVR32}" -ArgumentList "/s ${dll}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } \ No newline at end of file diff --git a/Fix-WindowsUpdate.ps1 b/Fix-WindowsUpdate.ps1 index 06ad03c..90d706d 100644 --- a/Fix-WindowsUpdate.ps1 +++ b/Fix-WindowsUpdate.ps1 @@ -7,7 +7,7 @@ $DEST_DIR = "${Env:WinDir}\SoftwareDistribution.old" ## Delete any existing folder from a previous execution of this script Write-Output "Deleting ""${DEST_DIR}""" Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } ## Stop Background Intelligent Transfer Services and Windows Update Control-Service -Stop -Name BITS @@ -16,7 +16,7 @@ Control-Service -Stop -Name wuauserv ## Rename the SoftwareDistribution folder, forcing Windows Update to recreate all metrics and redownload all updates Write-Output "Renaming ""${TARGET_DIR}"" to ""${DEST_DIR}""" Try { Rename-Item -Path $TARGET_DIR -NewName $DEST_DIR -Force } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } ## Start Windows Update and Background Intelligent Transfer Services Control-Service -Start -Name BITS @@ -27,9 +27,9 @@ Control-Service -Start -Name wuauserv ## but keep in mind this folder can be very large and takes up a lot of space. Write-Output "Deleting ""${DEST_DIR}""" Try { Remove-Item $DEST_DIR -Recurse -Force -ErrorAction SilentlyContinue } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } ## Force the Windows Update client to check for new updates 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 +Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Get-EventData.ps1 b/Get-EventData.ps1 index 6c7dc0b..bcaedc1 100644 --- a/Get-EventData.ps1 +++ b/Get-EventData.ps1 @@ -1,8 +1,8 @@ # This script depends on the host, port, username, and password being defined in the calling script -If ( -not($SFTPHost) ) { LogErr "SFTP host is not defined, this script will exit." ; Exit } -If ( -not($SFTPPort) ) { LogErr "SFTP port is not defined, this script will exit." ; Exit } -If ( -not($SFTPUser) ) { LogErr "SFTP username is not defined, this script will exit." ; Exit } -If ( -not($SFTPPass) ) { LogErr "SFTP password is not defined, this script will exit." ; Exit } +If ( -not($SFTPHost) ) { Write-Error "SFTP host is not defined, this script will exit." ; Exit } +If ( -not($SFTPPort) ) { Write-Error "SFTP port is not defined, this script will exit." ; Exit } +If ( -not($SFTPUser) ) { Write-Error "SFTP username is not defined, this script will exit." ; Exit } +If ( -not($SFTPPass) ) { Write-Error "SFTP password is not defined, this script will exit." ; Exit } $ExportedEvents = "${Env:TEMP}\${Env:COMPUTERNAME}_events.csv" @@ -27,7 +27,7 @@ ForEach ($Log in $Logs) { $LogName = $Log.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 } + Catch { Write-Error $_.Exception.Message } } # Deduplicate exported events @@ -36,7 +36,7 @@ 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 } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } # Upload to SFTP site If ( Test-Path $ExportedEvents ) { @@ -50,7 +50,7 @@ If ( Test-Path $ExportedEvents ) { $SFTPSession = New-SFTPSession -ComputerName $SFTPHost -Credential $SFTPCred -AcceptKey -Port $SFTPPort Write-Output "Uploading events to SFTP site" Try { Set-SFTPItem -SessionId $SFTPSession.SessionId -Path $ExportedEvents -Destination . -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } Finally { Remove-SFTPSession -SessionId $SFTPSession.SessionId } } diff --git a/Get-InstalledSoftware.ps1 b/Get-InstalledSoftware.ps1 index b31c424..e708fd6 100644 --- a/Get-InstalledSoftware.ps1 +++ b/Get-InstalledSoftware.ps1 @@ -11,10 +11,10 @@ Function Write-LineToFile { If ( -not (Test-Path $Path) ) { Write-Output "Creating file ""${Path}""" Try { New-Item -Path $Path -ItemType File -Force | Out-Null } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Try { Add-Content -Path $Path -Value $Line } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Function to test whether or not an item has a specified property @@ -68,7 +68,7 @@ Function Get-ItemPropertyInfo { ## Set $retval to a standard datetime format $retval = $date.ToString('yyyy-MM-dd') } - Catch { LogErr $_.Exception.Message; $retval = $origRetval } + Catch { Write-Error $_.Exception.Message; $retval = $origRetval } } Default {} } diff --git a/Install-4KVideoDownloader.ps1 b/Install-4KVideoDownloader.ps1 index eee5d6f..8895ca3 100644 --- a/Install-4KVideoDownloader.ps1 +++ b/Install-4KVideoDownloader.ps1 @@ -10,11 +10,11 @@ If (! (Test-Path "${Env:ProgramFiles}\4KDownload\4kvideodownloader\4kvideodownlo ## Install the app Write-Output "Installing 4K Video Downloader from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } ## Delete the installer Write-Output "Deleting downloaded installer from ""${INSTALLER}""" Try { Remove-Item -Path $INSTALLER -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } 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 36177fe..f58eb67 100644 --- a/Install-AdobeConnect.ps1 +++ b/Install-AdobeConnect.ps1 @@ -5,6 +5,6 @@ $URL = 'https://download.adobe.com/pub/connect/updaters/meeting/11_0/ConnectApp1 If ( IsURLValid $URL ) { Write-Output "Installing Adobe Connect from ${URL}" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${URL} /qn /norestart" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } 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 482b36e..ef7a2da 100644 --- a/Install-AteraAgent.ps1 +++ b/Install-AteraAgent.ps1 @@ -39,7 +39,7 @@ If ( $INSTALL ) { #Download and run the uninstall script $UninstallScript = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Uninstall-AteraAgent.ps1' Try { Start-Process "powershell.exe" -ArgumentList "-ExecutionPolicy Bypass -Noninteractive -File ""${UninstallScript}""" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } # Replace the '@' with '%40' - not sure why this is necessary, but it is @@ -51,12 +51,12 @@ If ( $INSTALL ) { # Install the agent Write-Output "Installing Atera agent from ""${AGENT_INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } # Delete the agent installer Write-Output "Deleting ""${AGENT_INSTALLER}""" Try { Remove-Item $AGENT_INSTALLER -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } If ( $PreviousInstall -and $ACCOUNT_ID -and $AGENT_ID -and $CUSTOMER_ID) { Write-Output "Restoring agent information from previous install" diff --git a/Install-ESETManagementAgent.ps1 b/Install-ESETManagementAgent.ps1 index 5680993..a33b9d5 100644 --- a/Install-ESETManagementAgent.ps1 +++ b/Install-ESETManagementAgent.ps1 @@ -7,17 +7,17 @@ $TEMPDIR = '{0}eset-protect-deployment' -f (Get-TempPath) If ( Test-Path $TEMPDIR ) { Write-Output """${TEMPDIR}"" already exists and will be deleted" Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } # Create $TEMPDIR Write-Output "Creating: ${TEMPDIR}" Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop } -Catch { LogErr $_.Exception.Message ; Exit } +Catch { Write-Error $_.Exception.Message ; Exit } # Write $CONFIG to install_config.ini Try { $CONFIG | WriteToFile_UTF8NoBOM -FilePath "${TEMPDIR}\install_config.ini" } -Catch { Write-Output "Cannot write configuration file! This script will exit." ; LogErr $_.Exception.Message ; Exit } +Catch { Write-Output "Cannot write configuration file! This script will exit." ; Write-Error $_.Exception.Message ; Exit } # Get bitness of endpoint and set $AGENTNAME If ( Is64bit ) { $AGENTNAME = "agent_x64.msi" } Else { $AGENTNAME = "agent_x86.msi" } @@ -31,9 +31,9 @@ Download-File -URL $URL -File $INSTALLER # Install the app 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 } +Catch { Write-Error $_.Exception.Message } # Delete the installer Write-Output "Deleting temp directory and its contents" Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } diff --git a/Install-EmberkomCloudBackup.ps1 b/Install-EmberkomCloudBackup.ps1 index f290cbd..6def3b2 100644 --- a/Install-EmberkomCloudBackup.ps1 +++ b/Install-EmberkomCloudBackup.ps1 @@ -25,7 +25,7 @@ $Installer = Download-File -URL $URL # Install the agent Write-Output "Installing Emberkom Cloud Backup agent" Try { Start-Process "${Installer}" -ArgumentList "/S" -Wait } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } # Add backup user to installed product Try { @@ -33,13 +33,13 @@ Try { Write-Output "Adding backup user account: ${MSP360Username}" Add-MBSUserAccount -User $MSP360Username -Password $MSP360Password } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } # Set the agent edition # Note: the product edition must be set *after* the user is added Write-Output "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition""" Try { Set-MBSAgentSetting -Edition $AgentEdition -Verbose } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } # Delete the desktop icon "${Env:PUBLIC}\Desktop\Emberkom Backup.LNK", diff --git a/Install-Enscape.ps1 b/Install-Enscape.ps1 index 8de0991..3f91cc9 100644 --- a/Install-Enscape.ps1 +++ b/Install-Enscape.ps1 @@ -5,11 +5,11 @@ $MSIURL = 'https://enscape-installer.chaosgroup.com/installer.enscape.io/Enscape $INSTALLER = Download-File -URL $MSIURL 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 } +Catch { Write-Error $_.Exception.Message } ## Delete installer Try { Write-Output "Deleting downloaded installation package" Remove-Item $INSTALLER -Force -ErrorAction SilentlyContinue } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } diff --git a/Install-LiquidFilesOutlookAgent.ps1 b/Install-LiquidFilesOutlookAgent.ps1 index b817086..b7c8494 100644 --- a/Install-LiquidFilesOutlookAgent.ps1 +++ b/Install-LiquidFilesOutlookAgent.ps1 @@ -22,14 +22,14 @@ If ($RunningProcess) { $INSTALLER = Download-File -URL $MSIURL 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 } +Catch { Write-Error $_.Exception.Message } # Delete installer Try { Write-Output "Deleting downloaded installation package" Remove-Item $INSTALLER -Force -ErrorAction SilentlyContinue } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } # Start the agent $PathToAgentExe64 = "${Env:ProgramFiles(x86)}\LiquidFiles Windows Agent\LiquidFilesWindowsAgent.exe" @@ -42,5 +42,5 @@ If ( Test-Path $PathToAgentExe64 ) { If ($PathToAgentExe) { Write-Output "Starting LiquidFiles agent" Try { Start-Process $PathToAgentExe } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } diff --git a/Install-Nextcloud.ps1 b/Install-Nextcloud.ps1 index 95658f1..89aa2cc 100644 --- a/Install-Nextcloud.ps1 +++ b/Install-Nextcloud.ps1 @@ -18,5 +18,5 @@ If ( Test-Path $InstallPath ) { Write-Output "Starting Nextcloud" Try { Start-Process $InstallPath } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } diff --git a/Install-OpenVPN.ps1 b/Install-OpenVPN.ps1 index fc5dc0c..69078c0 100644 --- a/Install-OpenVPN.ps1 +++ b/Install-OpenVPN.ps1 @@ -21,7 +21,7 @@ If ( IsAdmin ) { Write-Output "Deleting desktop shortcut: ${Shortcut}" Try { Remove-Item $Shortcut -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } 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 e2598bb..24f97af 100644 --- a/Install-SimpleInOut.ps1 +++ b/Install-SimpleInOut.ps1 @@ -9,9 +9,9 @@ $INSTALLER = Download-File -URL $URL # Install the app 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 } +Catch { Write-Error $_.Exception.Message } # Delete the 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 +Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Install-SpecsIntact.ps1 b/Install-SpecsIntact.ps1 index ac5394e..d329638 100644 --- a/Install-SpecsIntact.ps1 +++ b/Install-SpecsIntact.ps1 @@ -7,9 +7,9 @@ $INSTALLER = Download-File -URL $URL ## Install the app Write-Output "Installing latest version of SpecsIntact from ""${INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart" -Wait } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } ## Delete the 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 +Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Install-SyncroAgent.ps1 b/Install-SyncroAgent.ps1 index 3a73bf2..8d9ac48 100644 --- a/Install-SyncroAgent.ps1 +++ b/Install-SyncroAgent.ps1 @@ -23,9 +23,9 @@ Download-File -URL $URL -File "${AGENT_INSTALLER}" # Install the agent Write-Output "Installing Syncro agent from ""${AGENT_INSTALLER}""" Try { Start-Process "msiexec.exe" -ArgumentList "/i ""${AGENT_INSTALLER}"" /qn /norestart" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } # Delete the agent installer Write-Output "Deleting ""${AGENT_INSTALLER}""" Try { Remove-Item $AGENT_INSTALLER -Force } - Catch { LogErr $_.Exception.Message } \ No newline at end of file + Catch { Write-Error $_.Exception.Message } \ No newline at end of file diff --git a/Install-Wireguard.ps1 b/Install-Wireguard.ps1 index 7fead4e..e4a3e2a 100644 --- a/Install-Wireguard.ps1 +++ b/Install-Wireguard.ps1 @@ -10,15 +10,15 @@ If ( IsAdmin ) ## Install package $Installer = Download-File -URL $URL Try { Start-Process "msiexec.exe" -ArgumentList "/i ${Installer} /qn /norestart DO_NOT_LAUNCH=1" -Wait -ErrorAction Stop } - Catch { LogErr $_.Exception.Message ; Exit } + Catch { Write-Error $_.Exception.Message ; Exit } ## Delete installer Try { If ( Test-Path $Installer ) { Remove-Item $Installer -Force } } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } ## Install manager service Try { Start-Process "${Env:ProgramFiles}\WireGuard\wireguard.exe" -ArgumentList '/installmanagerservice' -Wait -ErrorAction SilentlyContinue } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } ## Create shortcut on Public desktop If ( $CreateDesktopShortcut ) { diff --git a/Install-ZeroTier.ps1 b/Install-ZeroTier.ps1 index 1330781..6c78cb6 100644 --- a/Install-ZeroTier.ps1 +++ b/Install-ZeroTier.ps1 @@ -28,7 +28,7 @@ If ( IsWindowsVersion -ge "6.1" ) { ## Attempt to stop/start the service Try { Restart-Service -Name ZeroTierOneService -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } ## Wait a few seconds before checking again Start-Sleep -Seconds 5 @@ -56,7 +56,7 @@ If ( IsWindowsVersion -ge "6.1" ) ## Join the network, if $ZTcli exists Write-Output "Joining ZeroTier network ${JoinNetwork}" Try { Start-Process $ZTcli -ArgumentList "join ${JoinNetwork}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { Write-Output "Could not find ""${ZTcli}""" } } @@ -73,7 +73,7 @@ If ( IsWindowsVersion -ge "6.1" ) { Write-Output "Deleting Start Menu shortcut from ""${ShortcutPath}""" Try { Remove-Item $ShortcutPath -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } diff --git a/Remove-DeltekVision.ps1 b/Remove-DeltekVision.ps1 index 172c7b5..d02ed3b 100644 --- a/Remove-DeltekVision.ps1 +++ b/Remove-DeltekVision.ps1 @@ -7,6 +7,6 @@ If ( Test-Path $APP_PATH ) { ## Delete the existing installed app Write-Output "Deleting ""${APP_PATH}""" Try { Remove-Item $APP_PATH -Recurse -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } 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 08829a4..a4e07b6 100644 --- a/Remove-OldFiles.ps1 +++ b/Remove-OldFiles.ps1 @@ -8,7 +8,7 @@ If ( $OlderThanDays -is [int] ) { Foreach ( $f in $files ) { $msg = "Deleting {0}" -f $f.FullName ; Write-Output $msg Try { Remove-Item $f -Force | Out-Null } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } 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/Test-InternetBandwidth.ps1 b/Test-InternetBandwidth.ps1 index 1acdaa3..87616ef 100644 --- a/Test-InternetBandwidth.ps1 +++ b/Test-InternetBandwidth.ps1 @@ -9,18 +9,18 @@ $WORKINGDIR = $ZIPFILE.Substring(0, $ZIPFILE.LastIndexOf('.')) If ( Test-Path $WORKINGDIR ) { Write-Output "Deleting existing directory: ""$WORKINGDIR""" Try { Remove-Item -Path $WORKINGDIR -Recurse -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Write-Output "Creating new directory: ""$WORKINGDIR""" Try { New-Item -Path $WORKINGDIR -ItemType Directory -Force | Out-Null } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } ## Extract $ZIPFILE to $WORKINGDIR Try { Add-Type -Assembly System.IO.Compression.FileSystem [IO.Compression.ZipFile]::ExtractToDirectory($ZIPFILE, $WORKINGDIR) } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } ## Run the SpeedTest CLI app $SPEEDTEST = "${WORKINGDIR}\speedtest.exe" @@ -44,7 +44,7 @@ If ( Test-Path $SPEEDTEST ) { Write-Output $RESULTS Write-Output "Finished internet bandwidth test" } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { Write-Output "The file does not exist at the expected path: ""${SPEEDTEST}""" } @@ -52,11 +52,11 @@ If ( Test-Path $SPEEDTEST ) { If ( Test-Path $ZIPFILE ) { Write-Output "Deleting downloaded zip file: ""$ZIPFILE""" Try { Remove-Item -Path $ZIPFILE -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { Write-Output "Downloaded zip file no longer exists: ""$ZIPFILE""" } If ( Test-Path $WORKINGDIR ) { Write-Output "Deleting directory from extracted zip file: ""$WORKINGDIR""" Try { Remove-Item -Path $WORKINGDIR -Recurse -Force } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { Write-Output "Directory from extracted zip file no longer exists: ""$WORKINGDIR""" } \ No newline at end of file diff --git a/Uninstall-AdobeFlash.ps1 b/Uninstall-AdobeFlash.ps1 index f4b9250..7bccbbc 100644 --- a/Uninstall-AdobeFlash.ps1 +++ b/Uninstall-AdobeFlash.ps1 @@ -11,7 +11,7 @@ If ( IsAdmin ) $UninstallProgram = $UninstallString -replace ' -maintain plugin', '' Write-Output "Running: ""${UninstallProgram}"" -uninstall" Try { Start-Process "${UninstallProgram}" -ArgumentList "-uninstall" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { Write-Output "Adobe Flash Player is not installed" } } diff --git a/Uninstall-EmberkomCloudBackup.ps1 b/Uninstall-EmberkomCloudBackup.ps1 index cdb7ee2..cb752ce 100644 --- a/Uninstall-EmberkomCloudBackup.ps1 +++ b/Uninstall-EmberkomCloudBackup.ps1 @@ -5,4 +5,4 @@ Import-Module -Name MSP360 ## Uninstall the agent Write-Output "Uninstalling Emberkom Cloud Backup agent" Try { Remove-MBSAgent -RemoveSettings -Force } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } diff --git a/Uninstall-MicrosoftOffice.ps1 b/Uninstall-MicrosoftOffice.ps1 index 7892d4f..ad27775 100644 --- a/Uninstall-MicrosoftOffice.ps1 +++ b/Uninstall-MicrosoftOffice.ps1 @@ -28,7 +28,7 @@ $ScriptArgs = "/ALL /QUIET /NOCANCEL" # Run the script Write-Output "Uninstalling all Click2Run versions of Office" Try { Start-Process "cscript.exe" -ArgumentList "//nologo ""${UninstallScript}"" ${ScriptArgs}" -Wait } -Catch { LogErr $_.Exception.Message } +Catch { Write-Error $_.Exception.Message } # Delete the downloaded script If ( Test-Path $UninstallScript ) { diff --git a/Uninstall-NCentralComponents.ps1 b/Uninstall-NCentralComponents.ps1 index bc3d1f9..fe6ae29 100644 --- a/Uninstall-NCentralComponents.ps1 +++ b/Uninstall-NCentralComponents.ps1 @@ -3,21 +3,21 @@ If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\PME\unins000.exe" ) { 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 } + Catch { Write-Error $_.Exception.Message } } ## Remove N-Central File Cache Service Agent If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\FileCacheServiceAgent\unins000.exe" ) { 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 } + Catch { Write-Error $_.Exception.Message } } ## Remove N-Central Request Handler Agent If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform\RequestHandlerAgent\unins000.exe" ) { 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 } + Catch { Write-Error $_.Exception.Message } } ## Remove Windows Software Probe @@ -25,14 +25,14 @@ 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 Write-Output "Uninstalling Windows Software Probe" Try { Start-Process "msiexec.exe" -ArgumentList "/X {${ProductCode}} /qn" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Remove Windows Agent If ( Test-Path "${ProgramFiles(x86)}\N-able Technologies\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 } + Catch { Write-Error $_.Exception.Message } } ## Remove NablePatchRepositoryService @@ -42,7 +42,7 @@ If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Remove Windows Software Probe Maintenance Service @@ -52,7 +52,7 @@ If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Remove Windows Software Probe Syslog Service @@ -62,7 +62,7 @@ If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Remove Windows Software Probe Service @@ -72,7 +72,7 @@ If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Remove Windows Agent Maintenance Service @@ -82,7 +82,7 @@ If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Remove Windows Agent Service @@ -92,31 +92,31 @@ If ( $Service.Length -gt 0 ) { Control-Service -Stop -Name $ServiceName Write-Output "Deleting the service: ""${ServiceName}""" Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } ## Remove "MspPlatform" directory If ( Test-Path "${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 } + Catch { Write-Error $_.Exception.Message } } ## Remove "N-able Technologies" directory If ( Test-Path "${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 } + Catch { Write-Error $_.Exception.Message } } ## Remove "N-able Technologies" registry key If ( Test-Path "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 } + Catch { Write-Error $_.Exception.Message } } If ( Test-Path "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 } + Catch { Write-Error $_.Exception.Message } } diff --git a/Uninstall-UnwantedDefaultApps.ps1 b/Uninstall-UnwantedDefaultApps.ps1 index 76c942a..041333f 100644 --- a/Uninstall-UnwantedDefaultApps.ps1 +++ b/Uninstall-UnwantedDefaultApps.ps1 @@ -61,14 +61,14 @@ If ( IsWindowsBuild -ge 9200 ) If ($PackageFullName) { Write-Output “Removing package: ${PackageFullName}” Try { Remove-AppxPackage -Package $PackageFullName } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } # If the provisioned package exists, uninstall it If ($ProPackageFullName) { Write-Output “Removing provisioned package: ${ProPackageFullName}” Try { Remove-AppxProvisionedPackage -PackageName $ProPackageFullName -Online -AllUsers } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } } Else { Write-Output "Cannot remove Appx packages because this endpoint is not running Windows 8 or higher" } diff --git a/Update-Wireguard.ps1 b/Update-Wireguard.ps1 index 75cea2d..6509705 100644 --- a/Update-Wireguard.ps1 +++ b/Update-Wireguard.ps1 @@ -13,7 +13,7 @@ If (IsAdmin) { If ( -not [string]::IsNullOrEmpty($PATH) ) { Write-Output "Updating Wireguard" Try { Start-Process $PATH -ArgumentList "/update" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } Write-Output "Finished updating Wireguard" } } diff --git a/Upload-Data.ps1 b/Upload-Data.ps1 index 47d0751..13a8e64 100644 --- a/Upload-Data.ps1 +++ b/Upload-Data.ps1 @@ -27,11 +27,11 @@ If ( $LFCLI ) { If ( $DeleteAfterUpload ) { Try { Start-Process "${LFCLI}" -ArgumentList "filedrop /url:${FiledropURL} /from:""${From}"" /subject:""${Subject}"" /msg:""${Message}"" /c:n /deleteAfterUpload /f:""${FileToUpload}""" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } Else { Try { Start-Process "${LFCLI}" -ArgumentList "filedrop /url:${FiledropURL} /from:""${From}"" /subject:""${Subject}"" /msg:""${Message}"" /c:n /f:""${FileToUpload}""" -Wait } - Catch { LogErr $_.Exception.Message } + Catch { Write-Error $_.Exception.Message } } } Else { Write-Output "The specified file does not exist: ""${FileToUpload}""" }