Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2.  
  3.  
  4. .INFORMATION
  5. ====================================================================================
  6.      Made with:           PrimalPad
  7.      Made by:             Christer
  8.      Organization:        A2G Gruppen AS
  9.  
  10.  
  11. .DESCRIPTION
  12. ====================================================================================
  13.  
  14.     IMPORTANT!
  15.  
  16.     First INSTALL this MODULE:
  17.     - Run PowerShell as administrator and enter the install commands below
  18.        
  19.         [AZSBTools] Used for getting the dates, like the first tuesday of the month
  20.             Install-Module AZSBTools -Force -AllowClobber -Scope CurrentUser -SkipPublisherCheck
  21.  
  22.     The Optimize-Volume cmdlet optimizes a volume, performing defragmentation, trim, slab consolidation, and storage tier processing.
  23.     If no parameter is specified, then the default operation will be performed per the drive type as follows.
  24.  
  25.     HDD, Fixed VHD, Storage Space. -Analyze -Defrag.
  26.     Tiered Storage Space. -TierOptimize.
  27.     SSD with TRIM support. -Retrim.
  28.     Storage Space (Thinly provisioned), SAN Virtual Disk (Thinly provisioned), Dynamic VHD, Differencing VHD. -Analyze -SlabConsolidate -Retrim.
  29.     SSD without TRIM support, Removable FAT, Unknown. No operation.
  30.    
  31.     This script will only run on the first friday of the month.
  32.     Schedule it to run every friday.
  33.    
  34. #>
  35.  
  36. $TargetDate = Get-DayOfMonth -DayOfWeek Friday -First
  37. $Today = Get-Date
  38.  
  39. if ($Today -like $TargetDate) {
  40.  
  41.     DISM /Online /Cleanup-Image /RestoreHealth
  42.     Repair-Volume -DriveLetter C -SpotFix
  43.     Optimize-Volume -DriveLetter C -ReTrim -Verbose
  44.  
  45. } else {
  46.  
  47.     Exit
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement