This commit is contained in:
2020-05-22 14:35:46 -04:00
parent c5b16d024c
commit 7907fe891b
15 changed files with 198 additions and 59 deletions
+9 -3
View File
@@ -1,3 +1,9 @@
Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppXDeploymentServer_*.evtx" }| Remove-Item -Force
Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppxErrorReport_*.txt" } | Remove-Item -Force
Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppXPackaging_*.evtx" }| Remove-Item -Force
## This script will remove runaway AppX temp files that can consume 100's of GB on an endpoint
## Only run this script on Windows 8 or higher endpoints
$WindowsVersion = [double]("{0}.{1}" -f ([System.Environment]::OSVersion.Version).Major,([System.Environment]::OSVersion.Version).Minor)
If ( $WindowsVersion -ge 6.2 ) {
Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppXDeploymentServer_*.evtx" }| Remove-Item -Force
Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppxErrorReport_*.txt" } | Remove-Item -Force
Get-ChildItem -Path "${Env:SystemRoot}\Temp" | Where { $_.Name -like "AppXPackaging_*.evtx" }| Remove-Item -Force
}
+3
View File
@@ -0,0 +1,3 @@
## This script will delete runaway CBS logs that can take up 100's of GB on an endpoint
Get-ChildItem -Path "${Env:WINDIR}\Logs\CBS" -File | Where { ( $_.Name -like "CbsPersist_*.log" ) -or ( $_.Name -like "CbsPersist_*.cab" ) } | Remove-Item -Force
+3 -4
View File
@@ -1,5 +1,6 @@
## Get contents of SYSTEM PATH environment variable
$CURRENT_PATH = (Get-Itemproperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path).Path
$REG_ENVVAR = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
$CURRENT_PATH = (Get-Itemproperty -Path $REG_ENVVAR -Name Path).Path
$NEW_PATH = $null
$REMOVE_PATH =$null
@@ -18,8 +19,6 @@ Foreach ( $path in $CURRENT_PATH.Split(";") )
}
}
Write-Output "New Path:`n`r${NEW_PATH}"
Write-Output "Removed Paths:`n`r${REMOVE_PATH}"
#Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $NEW_PATH
Set-ItemProperty -Path $REG_ENVVAR -Name Path -Value $NEW_PATH
@@ -1,6 +1,6 @@
[CmdletBinding()]
param(
[int]$OlderThan=30
[int]$OlderThan=7
)
## Create a new timespan to compare with last write date of the target directory
@@ -10,6 +10,6 @@ $timedelta = New-TimeSpan -Days $OlderThan
Foreach ( $item in (Get-ChildItem -Path "${Env:WinDir}\TEMP") ) {
## If it's older than the number of days specified, recursively delete the directory
If ( $item.LastWriteTime -lt ((Get-Date) - $timedelta) ) { Remove-Item $item.FullName -Recurse -Force }
If ( $item.LastWriteTime -lt ((Get-Date) - $timedelta) ) { Remove-Item $item.FullName -Recurse -ErrorAction SilentlyContinue -Force }
}
+4
View File
@@ -0,0 +1,4 @@
@echo off
REM Disable Windows 10 screen timeout
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v InactivityTimeoutSecs /t REG_DWORD /d 0 /f
+2 -2
View File
@@ -1,7 +1,7 @@
## Get the correct URL
If ( Test-Path "${Env:ProgramFiles(x86)}" )
{ $URL = 'https://emberkom.s3.amazonaws.com/management/installers/amazon-corretto-8.222.10.3-windows-x64.msi' }
Else { $URL = 'https://emberkom.s3.amazonaws.com/management/installers/amazon-corretto-8.222.10.3-windows-x86.msi' }
{ $URL = 'https://corretto.aws/downloads/latest/amazon-corretto-11-x64-windows-jdk.msi' }
Else { $URL = 'https://corretto.aws/downloads/latest/amazon-corretto-8-x86-windows-jdk.msi' }
## Install Amazon Corretto
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i ${URL} /qn /norestart" -Wait
+23
View File
@@ -0,0 +1,23 @@
[CmdletBinding()]
param(
[string]$AGENT_URL,
[string]$AGENT_FILENAME='EmberkomAgentSetup.exe'
)
$TEMP = [System.IO.Path]::GetTempPath()
$AGENT_INSTALLER = "${TEMP}\${AGENT_FILENAME}"
## Make sure the AGENT_URL is specified
If ( $AGENT_URL )
{
## Make sure we need to install the agent
If ( !(Test-Path 'HKLM:SOFTWARE\N-able Technologies\NcentralAsset') -and !(Test-Path 'SOFTWARE\Wow6432Node\N-able Technologies\NcentralAsset'))
{
## Download the agent
If ( Test-Path $AGENT_INSTALLER ) { Remove-Item $AGENT_INSTALLER -Force }
(New-Object System.Net.WebClient).DownloadFile("${AGENT_URL}", $AGENT_INSTALLER)
## Install the agent
Start-Process $AGENT_INSTALLER -ArgumentList '/quiet /passive' -Wait
}
}
+6 -2
View File
@@ -1,7 +1,11 @@
## Only specify a network ID here if it isn't specified in an environment variable (RMM or endpoint) or you need to override that value:
param(
[string]$JoinNetwork
)
## Only specify a network ID here if it isn't specified in an environment variable (RMM or endpoint) or you need to override that value:
$JoinNetwork = ''
## If $JoinNetwork is not specified at the command line, use Syncro's ZTNetworkID customer custom field if it exists
## If $JoinNetwork is not specified at the command line, use the ZTNetworkID customer custom field if it exists
If ( (-not $JoinNetwork) -and ($ZeroTierNetworkID) ) { $JoinNetwork = $ZeroTierNetworkID }
## Get Windows version
+25
View File
@@ -0,0 +1,25 @@
## Set the path to Deltek Vision
$APP_PATH = "${Env:UserProfile}\AppData\Local\Apps\2.0"
## Test to make sure it's installed for the current user before continuing
if ( Test-Path $APP_PATH ) {
## Stop the process if it's currently running
try {
$Process = Get-Process -Name "DeltekVision" -ErrorAction SilentlyContinue
if ( !($Process -eq $null) ) { Stop-Process -Name $ProcessName }
}
catch {
Write-Host "Deltek Vision is running but couldn't be stopped!"; exit
}
## Delete the existing installed app
try {
Remove-Item $APP_PATH -Recurse -Force
}
catch {
Write-Host "There was a problem while deleting the installed version of Deltek Vision!"; exit
}
Write-Host "Deltek Vision was successfully uninstalled."
}
+24 -10
View File
@@ -24,29 +24,43 @@ $RegKeys = @(
)
## Find the most likely path to the TeamViewer uninstaller
If ( Test-Path "${Env:ProgramFiles(x86)}" ) {
If ( Test-Path "${Env:ProgramFiles(x86)}" )
{
$INSTALLDIR = $(Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\TeamViewer").InstallationDirectory
} Else {
}
Else
{
$INSTALLDIR = $(Get-ItemProperty -Path "HKLM:\SOFTWARE\TeamViewer").InstallationDirectory
}
## Kill all running instances of TeamViewer
Get-Process | Where { $_.Name -like "*TeamViewer*" }
If ( Test-Path "${INSTALLDIR}\uninstall.exe" ) { Start-Process "${INSTALLDIR}\uninstall.exe" -ArgumentList "/S" -Wait }
If ( Test-Path "${INSTALLDIR}\uninstall.exe" )
{ Start-Process "${INSTALLDIR}\uninstall.exe" -ArgumentList "/S" -Wait }
## Loop through each path in $UninstallerPaths and test if each one exists.
## If a path exists, silently run the uninstaller and then delete the directory.
Foreach ($uninstaller in $UninstallerPaths) {
if ( Test-Path "${uninstaller}" ) { Start-Process "${uninstaller}" -ArgumentList "/S" -Wait }
if ( Test-Path "${(Get-Item $uninstaller).Directory.FullName}" ) { Remove-Item "${(Get-Item $uninstaller).Directory.FullName}" -Recurse }
Foreach ($uninstaller in $UninstallerPaths)
{
If ( Test-Path "${uninstaller}" )
{
## Run the uninstaller
Start-Process "${uninstaller}" -ArgumentList "/S" -Wait
## Remove the directory
$dirname = $(Get-Item $uninstaller).Directory.FullName
Remove-Item "${dirname}" -Recurse -ErrorAction SilentlyContinue
}
}
## Remove each registry key in $RegKeys
Foreach ($key in $RegKeys) {
if ( Test-Path $key ) { Remove-Item $key -Recurse }
Foreach ($key in $RegKeys)
{
If ( Test-Path $key ) { Remove-Item $key -Recurse }
}
## Remove the TeamViewer service
Start-Process "sc.exe" -ArgumentList "delete TeamViewer"
Start-Process "sc.exe" -ArgumentList "delete TeamViewer_Service"
Start-Process "sc.exe" -ArgumentList "delete TeamViewer" -Wait
Start-Process "sc.exe" -ArgumentList "delete TeamViewer_Service" -Wait
+9 -8
View File
@@ -1,9 +1,10 @@
If ( Test-Path "${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 10 Host.lnk" ) {
Remove-Item "${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 10 Host.lnk" -Force
}
If ( Test-Path "${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 12 Host.lnk" ) {
Remove-Item "${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 12 Host.lnk" -Force
}
If ( Test-Path "${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 14 Host.lnk" ) {
Remove-Item "${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 14 Host.lnk" -Force
$Paths = @(
"${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 10 Host.lnk",
"${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 12 Host.lnk",
"${Env:SystemDrive}\Users\Public\Desktop\TeamViewer 14 Host.lnk",
"${Env:SystemDrive}\Users\Public\Desktop\TeamViewer Host.lnk" )
Foreach ( $path in $Paths )
{
If ( Test-Path $path ) { Remove-Item $path -Force }
}
+2
View File
@@ -0,0 +1,2 @@
## Enable SMB v1
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol -NoRestart
+21 -15
View File
@@ -300,20 +300,25 @@ Function Clean-Files($Items,$SageSetNumber) {
}
## Get the specified cleaning categories and run each one
If ( $All ) {
$User = $true
$System = $true
$WindowsUpdate = $true
$WindowsPreviousVersions = $true
$Invasive = $true
$Misc = $true
}
If ( $User ) { Clean-Files $UserItems $UserItemsSageSetNumber }
If ( $System ) { Clean-Files $SystemItems $SystemItemsSageSetNumber }
If ( $WindowsUpdate ) { Clean-Files $WindowsUpdateItems $WindowsUpdateItemsSageSetNumber }
If ( $WindowsPreviousVersions ) { Clean-Files $WindowsPreviousVersionsItems $WindowsPreviousVersionsItemsSageSetNumber }
If ( $Invasive ) { Clean-Files $InvasiveItems $InvasiveItemsSageSetNumber }
If ( $Misc ) { Clean-Files $MiscItems $MiscItemsSageSetNumber }
## Only run if cleanmgr.exe is present on the target endpoint.
If ( Test-Path "${Env:SYSTEMROOT}\System32\cleanmgr.exe" )
{
If ( $All ) {
$User = $true
$System = $true
$WindowsUpdate = $true
$WindowsPreviousVersions = $true
$Invasive = $true
$Misc = $true
}
If ( $User ) { Clean-Files $UserItems $UserItemsSageSetNumber }
If ( $System ) { Clean-Files $SystemItems $SystemItemsSageSetNumber }
If ( $WindowsUpdate ) { Clean-Files $WindowsUpdateItems $WindowsUpdateItemsSageSetNumber }
If ( $WindowsPreviousVersions ) { Clean-Files $WindowsPreviousVersionsItems $WindowsPreviousVersionsItemsSageSetNumber }
If ( $Invasive ) { Clean-Files $InvasiveItems $InvasiveItemsSageSetNumber }
If ( $Misc ) { Clean-Files $MiscItems $MiscItemsSageSetNumber }
} Else { Write-Output "cleanmgr.exe does not exist!" }
## Function to delete each iTunes backup directory
Function Delete-iTunesBackups($dir) {
@@ -335,7 +340,8 @@ If ( $iTunesBackups ) {
## List of accounts to exclude
$ExcludedUsers = @("Public",
"All Users")
"All Users",
"Administrator")
## Empty array to hold the user directories to clean
$DirectoriesToProcess = @()
+30 -13
View File
@@ -1,36 +1,53 @@
## Make sure the computer is running Windows 10
If ( ([System.Environment]::OSVersion.Version).Major -ge 10 ) {
## Make sure the endpoint isn't already running 1809
If ( ([System.Environment]::OSVersion.Version).Build -lt 18362 ) {
## Make sure the endpoint isn't already running 1909
If ( ([System.Environment]::OSVersion.Version).Build -lt 18363 ) {
## Set the directory where the Windows Update Assistant will be downloaded to
$DOWNLOADS = "${Env:TEMP}"
## URL to the latest version of the Windows Update Assistant
$URL = 'https://download.microsoft.com/download/B/C/F/BCF2D763-F118-4A85-9E63-AEAED1B9E98E/Windows10Upgrade9252.exe'
## URL to the 1909 version of the Windows Update Assistant
$URL = 'https://download.microsoft.com/download/9/b/f/9bf08afb-bfd8-488a-9ce6-90134cea4d8f/Windows10Upgrade9252.exe'
## Uninstall previous Windows 10 Update Assistant
If ( Test-Path "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" )
{ Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait }
{
Write-Output "Uninstalling existing Windows 10 Update Assistant"
Start-Process "${Env:SystemDrive}\Windows10Upgrade\Windows10UpgraderApp.exe" -ArgumentList '/ForceUninstall' -Wait
}
## Create download directory
If (!( Test-Path $DOWNLOADS ))
{ New-Item -ItemType Directory -Path $DOWNLOADS }
## Create download directory if not using $Env:TEMP
#If (!( Test-Path $DOWNLOADS ))
#{
# Write-Output "Creating "${DOWNLOADS}"
# New-Item -ItemType Directory -Path $DOWNLOADS
#}
## Download Windows 10 Update Assistant
$FILENAME = Split-Path $URL -leaf
If (!( Test-Path "${DOWNLOADS}\${FILENAME}" ))
{ (New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}") }
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
{
Write-Output "Deleting existing installer: ${DOWNLOADS}\${FILENAME}"
Remove-Item "${DOWNLOADS}\${FILENAME}" -Force -ErrorAction SilentlyContinue
}
Write-Output "Downloading ${URL} to ${DOWNLOADS}\${FILENAME}"
(New-Object System.Net.WebClient).DownloadFile($URL,"${DOWNLOADS}\${FILENAME}")
## Install and run the Windows 10 Update Assistant
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
{ Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" -Wait }
{
Write-Output "Launching installer: ${DOWNLOADS}\${FILENAME}"
Start-Process -FilePath "${DOWNLOADS}\${FILENAME}" -Wait
}
## Delete the downloaded program
If ( Test-Path "${DOWNLOADS}\${FILENAME}" )
{ Remove-Item "${DOWNLOADS}\${FILENAME}" }
{
Write-Output "Deleting installer: ${DOWNLOADS}\${FILENAME}"
Remove-Item "${DOWNLOADS}\${FILENAME}"
}
} Else { Write-Host "This endpoint is already running Windows 10 1809." }
} Else { Write-Host "This endpoint is already up to date." }
} Else { Write-Host "This endpoint is not running Windows 10." }
+35
View File
@@ -0,0 +1,35 @@
[CmdletBinding()]
param(
[string]$Name,
[switch]$Force=$false
)
If ( $Name )
{
## Get all matching processes
$Processes = Get-Process | Where { $_.Name -ilike $Name }
## Get the total number of matching processes
$NumMatches = $Processes.Count
If ( $NumMatches -ge 1 )
{
## Forcefully close matching processes
If ( $Force )
{
Foreach ( $proc in $Processes ) { Stop-Process $proc -Force -ErrorAction SilentlyContinue }
Write-Output "Forcefully closed ${NumMatches} matching instance(s) of ${Name}"
}
## Gracefully close matching processes
Else
{
Foreach ( $proc in $Processes ) { $proc.CloseMainWindow() | Out-Null }
Write-Output "Gracefully closed ${NumMatches} matching instance(s) of ${Name}"
}
}
Else { Write-Output "No running processes match the name ${Name}" }
}
Else { Write-Output "No process name was specified!" }