ExTools-Supplemental.psm1
################################################################################################## # Exbabylon Supplemental List of Functions # # Step 1: Go to %windir%\System32\WindowsPowerShell\v1.0\Modules and create a new folder called # "Exbabylon" without the quotation marks if the folder doesn't already exist. # Step 2: Add this ExTools-Supplemental.psm1 file to the new Exbabylon folder that you just created # Step 3: You can now use all functions in this file by calling the function name # Step 4: You can see a list of all functions in this module by running the below line of code: # Get-Command -Module Exbabylon ################################################################################################## ################################################################################################## # Check-Module # Checks to see if Module is installed on the device and installs it if it doesn't exist ################################################################################################## Function Check-Module ([string] $ModuleToFind){ $ModuleList = Get-Module -ListAvailable $ModuleExists = $false #Iterate through list and check if the module exists ForEach($Module in $ModuleList){ If($Module.Name -eq $ModuleToFind){ $ModuleExists = $true } } #Install Mmdule if missing If($ModuleExists -eq $false){ Write-Host "Module Doesn't Exist" Write-Host "Now Installing $ModuleToFind..." Try { Install-Module $ModuleToFind } Catch { Write-Host "Couldn't Install $ModuleToFind" } } else { Write-Host "$ModuleToFind exists and doesn't need to be installed" } } ################################################################################################## # Fix-PrintSpool # Stops Print Spool service, removes the oldest print job, then starts service again ################################################################################################## Function Fix-PrintSpool(){ $SpoolPath = "C:\Windows\System32\spool\PRINTERS" #Turn off Print Spooler Service $PrintSpooler = Get-Service | Where { $_.DisplayName -eq 'Print Spooler' } Stop-Service $PrintSpooler Write-Host $PrintSpooler.DisplayName $PrintSpooler.Status #Remove the oldest print job from spool file path Commented Code#Dir $SpoolPath | Sort lastwritetime | Select -First 1 | Remove-Item #Turn on Print Spooler Service Start-Service $PrintSpooler Write-Host $PrintSpooler.DisplayName $PrintSpooler.Status } |