major change to override Write-Error func

This commit is contained in:
2023-10-05 13:17:18 -04:00
parent bbb4884818
commit 5f4b4565de
42 changed files with 114 additions and 114 deletions
+4 -4
View File
@@ -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
}
}
+11 -11
View File
@@ -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 }
#Catch { Write-Error $_.Exception.Message }
+1 -1
View File
@@ -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" }
+2 -2
View File
@@ -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'
+3 -3
View File
@@ -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 }
}
+1 -1
View File
@@ -1,3 +1,3 @@
Write-Output "Clearing Outlook auto complete cache"
Try { Start-Process "outlook.exe" -ArgumentList "/CleanAutoCompleteCache" -ErrorAction Stop }
Catch { LogErr $_.Exception.Message }
Catch { Write-Error $_.Exception.Message }
+2 -2
View File
@@ -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!"
}
+2 -2
View File
@@ -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",
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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 }
Catch { Write-Error $_.Exception.Message }
+1 -1
View File
@@ -1,2 +1,2 @@
Try { Start-Process "gpupdate" -ArgumentList '/force' -Wait }
Catch { LogErr $_.Exception.Message }
Catch { Write-Error $_.Exception.Message }
+3 -3
View File
@@ -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" }
+1 -1
View File
@@ -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}""" }
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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 }
}
}
+4 -4
View File
@@ -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 }
Catch { Write-Error $_.Exception.Message }
+7 -7
View File
@@ -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 }
}
+3 -3
View File
@@ -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 {}
}
+2 -2
View File
@@ -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!" }
+1 -1
View File
@@ -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}" }
+3 -3
View File
@@ -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"
+5 -5
View File
@@ -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 }
+3 -3
View File
@@ -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",
+2 -2
View File
@@ -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 }
+3 -3
View File
@@ -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 }
}
+1 -1
View File
@@ -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 }
}
+1 -1
View File
@@ -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" }
+2 -2
View File
@@ -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 }
Catch { Write-Error $_.Exception.Message }
+2 -2
View File
@@ -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 }
Catch { Write-Error $_.Exception.Message }
+2 -2
View File
@@ -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 }
Catch { Write-Error $_.Exception.Message }
+3 -3
View File
@@ -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 ) {
+3 -3
View File
@@ -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 }
}
}
+1 -1
View File
@@ -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}" }
+1 -1
View File
@@ -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" }
+6 -6
View File
@@ -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""" }
+1 -1
View File
@@ -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" }
}
+1 -1
View File
@@ -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 }
+1 -1
View File
@@ -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 ) {
+15 -15
View File
@@ -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 }
}
+2 -2
View File
@@ -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" }
+1 -1
View File
@@ -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"
}
}
+2 -2
View File
@@ -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}""" }