Skip to content

Instantly share code, notes, and snippets.

View mark05e's full-sized avatar

mark05E mark05e

View GitHub Profile
@mark05e
mark05e / DriveClean.ps1
Last active March 7, 2025 00:14 — forked from pmsmith/DriveClean.ps1
Simple script to clear temp files and browser cache/history
#------------------------------------------------------------------#
#- Clear-GlobalWindowsCache #
#------------------------------------------------------------------#
Function Clear-GlobalWindowsCache {
Remove-CacheFiles 'C:\Windows\Temp'
Remove-CacheFiles "C:\`$Recycle.Bin"
Remove-CacheFiles "C:\Windows\Prefetch"
C:\Windows\System32\rundll32.exe InetCpl.cpl, ClearMyTracksByProcess 255
C:\Windows\System32\rundll32.exe InetCpl.cpl, ClearMyTracksByProcess 4351
}
# no longer works Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://api.cacher.io/raw/0fcd76d0761e565a8c4e/e62a66f046a5c4645ad5/start-cleanup'))
# Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://api.cacher.io/raw/0fcd76d0761e565a8c4e/61fb2ad04da370ab61c9/start-cleanup'))
Function Start-Cleanup {
<#
.SYNOPSIS
Automate cleaning up a C:\ drive with low disk space
.DESCRIPTION
Cleans the C: drive's Window Temperary files, Windows SoftwareDistribution folder,
the local users Temperary folder, IIS logs(if applicable) and empties the recycling bin.
$rootPath = "C:\Users"
#Chrome
Get-ChildItem -Path "$rootPath\*\AppData\Local\Google\Chrome\User Data\Default\Service Worker\CacheStorage" -force | get-childitem | Remove-Item -Recurse
Get-ChildItem -Path "$rootPath\*\AppData\Local\Google\Chrome\User Data\Default\Cache" -force | get-childitem | Remove-Item -Recurse
Get-ChildItem -Path "$rootPath\*\AppData\Local\Google\Chrome\User Data\Default\Code Cache" -force | get-childitem | Remove-Item -Recurse
#Edge
Get-ChildItem -Path "$rootPath\*\AppData\Local\Microsoft\Edge\User Data\Default\Service Worker\CacheStorage" -force | get-childitem | Remove-Item -Recurse
Get-ChildItem -Path "$rootPath\*\AppData\Local\Microsoft\Edge\User Data\Default\Cache" -force | get-childitem | Remove-Item -Recurse
@mark05e
mark05e / uninstall-microsoft365.ps1
Last active January 15, 2025 02:37
Uninstall the default office 365 installation that comes preinstalled. Maintenance Note - https://gist.github.com/mark05e/0a04a54c1e8489c770bd91e4910d7df9
#ref: https://www.reddit.com/r/sysadmin/comments/jjtpnp/script_to_silently_uninstall_builtin_office_365/
Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration
$OfficeUninstallStrings = ((Get-ItemProperty "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*") `
+ (Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") |
Where {$_.DisplayName -like "*Microsoft 365*"} |
Select UninstallString).UninstallString
ForEach ($UninstallString in $OfficeUninstallStrings) {
#ref: http://eddiejackson.net/wp/?p=23710
# https://www.adobe.com/devnet-docs/acrobatetk/tools/AdminGuide/cmdline.html#msi-support
# https://www.adobe.com/devnet-docs/acrobatetk/tools/ReleaseNotesDC/index.html#id4
# https://www.itninja.com/blog/view/how-to-deploy-adobe-reader-xi-11-0-02-through-gpo
# https://www.itninja.com/question/best-way-to-install-adobe-reader-11-0-11-msp-file
# Variables
$WebFile = "https://ardownload2.adobe.com/pub/adobe/acrobat/win/Acrobat2017/1701130197/Acrobat2017Upd1701130197.msp"
$PPath = "C:\TempPath\AdobeAcrobat2017"
#ref: http://eddiejackson.net/wp/?p=23710
$PPath=$args[0]
Write-Host $PPath
if ($PPath -eq $null){ $PPath = "C:\Temp\" }
$ProcName = "GoogleEarthWin.exe"
$WebFile = "https://dl.google.com/earth/client/advanced/current/GoogleEarthWin.exe"
New-Item -ItemType "directory" -Path $PPath
(New-Object System.Net.WebClient).DownloadFile($WebFile,"$PPath\$ProcName");Start-Process ("$PPath\$ProcName")
#-------------------------------------------------------------------#
# ScriptName : SetWall.ps1 #
# Description : Force a Desktop wallpaper Refresh #
# Credits : Unknown (if you know original creator, let us know) #
# #
# Date : 01 July 2020 #
# Ref : https://c-nergy.be/blog/?p=15291 #
#-------------------------------------------------------------------#
#Modify Path to the picture accordingly to reflect your infrastructure
@mark05e
mark05e / import-python.cmd
Last active November 2, 2023 02:46
for embeddable python files, place this inside python root directory and call from your scripts
set scriptDir=%~dp0
set invokeDir=%CD%
cd /d %scriptDir%
set PY_EXE=%CD%
set PY_PIP=%CD%\Scripts
set PY_LIB=%CD%\Lib;%CD%\Lib\site-packages
set PATH=%PY_EXE%;%PY_PIP%;%PY_LIB%;%PATH%
cd /d %invokeDir%