Upload files to "/"

This commit is contained in:
aaron 2023-12-18 18:01:19 +00:00
parent 65a94ebc5b
commit 84b08e5abe
5 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,68 @@
#Script to Enable Volume Shadow Copies with Custom Schedule, and disable any Default VSS tasks if there are any.
#Setting Variables
$logPath = "C:\Logs"
$date = Get-Date -Format yyyy-MM-dd
$ScheduledTasks = @()
$DisabledTasks = @()
New-Item -ItemType Directory -Force -Path $logPath
#Enable VSS and Set tasks
$Disks = Get-Volume | Where-Object {$_.DriveType -eq "Fixed"} | Where-Object {$_.DriveLetter -ne $null} | Where-Object {$_.Size -gt 5GB}
$offset = New-TimeSpan
$offsetInterval = New-TimeSpan -Minutes 15
foreach ($Disk in $Disks) {
# Enable Shadows
vssadmin add shadowstorage /for=$($Disk.DriveLetter): /on=$($Disk.DriveLetter): /maxsize=10%
# Set Shadow Copy Scheduled Task for C: 06:00, 12:00 and 17:00
$time1 = New-TimeSpan -Hours 6
$time2 = New-TimeSpan -Hours 12
$time3 = New-TimeSpan -Hours 17
$Argument = "-command ""C:\Windows\system32\vssadmin.exe create shadow /for=$($Disk.DriveLetter):"""
$Action = new-scheduledtaskaction -execute "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Argument $Argument
$Trigger1 = new-scheduledtasktrigger -daily -at ($time1 + $offset).ToString()
$Trigger2 = new-scheduledtasktrigger -daily -at ($time2 + $offset).ToString()
$Trigger3 = new-scheduledtasktrigger -daily -at ($time3 + $offset).ToString()
Register-ScheduledTask -TaskName "ShadowCopy $($Disk.DriveLetter) drive" -Trigger $Trigger1,$Trigger2,$Trigger3 -Action $Action -Description "ShadowCopy for $($Disk.DriveLetter) drive" -user "NT AUTHORITY\SYSTEM" -RunLevel Highest -Force
$offset = $offset + $offsetInterval
}
#Disable Default tasks
$ScheduledTasks = Get-ScheduledTask -TaskName "ShadowCopyVolume{*}"
$DisabledTasks = foreach ($Task in $ScheduledTasks){Disable-ScheduledTask -TaskName $Task.TaskName}
$DisabledTasks | ConvertTo-html -Property TaskName, State | Out-File "$logPath\$date-Shadows.html"
if (!$DisabledTasks) {Write-Host "No Default VSS Tasks Disabled"}
else {Write-Host "Default VSS Tasks have been disabled. Please see the log on Device to see details: C:\DiscStuff\Logs"}
#Update Custom fields
$ScheduledTasks = Get-ScheduledTask -TaskName "ShadowCopy*"
$DefaultTasks = Get-ScheduledTask -TaskName "ShadowCopyVolume{*}"
$CustomTasks = Get-ScheduledTask -TaskName "ShadowCopy * drive"
$VSS = [PSCustomObject]@{
enabled = $false
type = $null
}
#No Tasks
if ($ScheduledTasks -eq $null)
{Write-Host "No VSS Tasks"}
#Default Tasks
elseif ($DefaultTasks.State -ne "Disabled")
{Write-Host "Default VSS Tasks Enabled"; $VSS.enabled = $true; $VSS.type = "Default"}
#Default Tasks Disabled and No Custom Tasks
if (($DefaultTasks.State -eq "Disabled") -and ($CustomTasks -eq $null))
{Write-Host "Default VSS Tasks Disabled and NO Custom VSS Tasks"; $VSS.enabled = $false; $VSS.type = "Default"}
#Default Tasks Disabled and Custom Tasks Enabled
if ((($DefaultTasks.State -eq "Disabled") -or ($DefaultTasks -eq $null)) -and ($CustomTasks -ne $null))
{Write-Host "Default VSS Tasks Disabled and Custom VSS Tasks Enabled"; $VSS.enabled = $true; $VSS.type = "Custom"}
if ($Host.Version.Major -gt 4){Write-Host $VSS}
elseif ($Host.Version.Major -lt 5){$VSS}

7
Fix-FileSystem.ps1 Normal file
View File

@ -0,0 +1,7 @@
# Runs the sfc and dism commands to fix any issues with a file system
sfc /scannow
dism /online /cleanup-image /CheckHealth
dism /online /cleanup-image /ScanHealth
dism /online /cleanup-image /startcomponentcleanup
dism /online /cleanup-image /restorehealth

4
Fix-NoTaskbar.bat Normal file
View File

@ -0,0 +1,4 @@
# Force restarts Windows File Explorer to fix a bug where the task bar is missing.
taskkill /f /im explorer.exe
explorer.exe

View File

@ -0,0 +1,3 @@
# Gets a list of installed programs
Get-WmiObject -Class Win32_Product -Property Name | Select-Object name

26
Get-OSTFileSize.ps1 Normal file
View File

@ -0,0 +1,26 @@
# Generates a list of all user's OST file sizes
$UserFolder = "C:\Users"
$OutlookFolder = "AppData\Local\Microsoft\Outlook"
class OST {
[string]$name
[float]$size
}
Get-ChildItem -Path $UserFolder | ForEach-Object {
$User = $_
$Folder = "$User\$OutlookFolder"
if ($(Test-Path -Path $Folder)){
$FoundFiles = Get-ChildItem $Folder -Filter *.ost | Where-Object {$_.Length / 1GB -gt 1}
$FoundFiles | Select-Object FullName, Length | ForEach-Object {
$Name = $_.FullName
$Size = [Math]::Round(($_.Length / 1GB), 2)
$ost = [OST]::new()
$ost.name = $Name
$ost.size = $Size
}
}
}
$ost