tweaking wip scripts

This commit is contained in:
silversword411 2021-05-18 23:22:45 -04:00
parent 57129cf934
commit a6f7e446de
No known key found for this signature in database
GPG Key ID: 6F4BD176F56B50CA
6 changed files with 32 additions and 31 deletions

View File

@ -1,18 +0,0 @@
# Needs to be parameterized: $icofile, $URL, $ShortcutPath
# Need to change paths and test/create if don't exist
wget "https://www.example.com/logos/example.ico" -outfile "c:\agent\example.ico"
$WshShell = New-Object -comObject WScript.Shell
$path = "C:\Users\All Users\desktop\example.url"
$targetpath = "https://example.com/"
$iconlocation = "c:\agent\example.ico"
$iconfile = "IconFile=" + $iconlocation
$Shortcut = $WshShell.CreateShortcut($path)
$Shortcut.TargetPath = $targetpath
$Shortcut.Save()
Add-Content $path "HotKey=0"
Add-Content $path "$iconfile"
Add-Content $path "IconIndex=0"

View File

@ -1,3 +1,5 @@
REM Print Spooler reset script. Will stop spooler, fix permissions on print folders, clear all files in print queues, and restart spooler service.
REM Stop Print Spooler
net stop "Spooler"

View File

@ -1,2 +0,0 @@
net stop "Print Spooler"
net start "Print Spooler"

View File

@ -0,0 +1,25 @@
<#
.Synopsis
Restart Print Spooler Service
.DESCRIPTION
Will force-restart the spooler service. With additional command parameter will also delete any pending print jobs
.EXAMPLE
Another example of how to use this cmdlet
.OUTPUTS
Any print jobs that are deleted
.NOTES
v1.0 5/2021
https://github.com/silversword411
.FUNCTIONALITY
Print Spooler Troubleshooting, restarts spooler service. Can also delete all print jobs that are pending
#>
#Restart Spooler service
Restart-Service -Name spooler -Force
#Deletes All print jobs within the last 15 years
$PrintJobs = get-wmiobject -class "Win32_PrintJob" -namespace "root\CIMV2" -computername . | Where-Object { [System.Management.ManagementDateTimeConverter]::ToDateTime($_.TimeSubmitted) -lt (Get-Date).AddDays(-5500) }
foreach ($job in $PrintJobs) {
# Write-Host "Canceling job $($job.JobId)"
$job.Delete()
}

View File

@ -1,8 +0,0 @@
#Update with command parameters
#Deletes All print jobs within the last 2 days
$PrintJobs = get-wmiobject -class "Win32_PrintJob" -namespace "root\CIMV2" -computername . | Where-Object { [System.Management.ManagementDateTimeConverter]::ToDateTime($_.TimeSubmitted) -lt (Get-Date).AddDays(-2) }
foreach ($job in $PrintJobs) {
# Write-Host "Canceling job $($job.JobId)"
$job.Delete()
}

View File

@ -1,7 +1,9 @@
md -Path 'C:\agent' -Force
wget "http://www.yourwebsite.com/logos/yourico.ico" -outfile "c:\agent\yourico.ico"
mkdir -Path 'C:\agent' -Force
Invoke-WebRequest "http://www.yourwebsite.com/logos/yourico.ico" -outfile "c:\agent\yourico.ico"
$WshShell = New-Object -comObject WScript.Shell
$path = "C:\Users\All Users\desktop\Jaxsupport.url"
$path = "C:\Users\All Users\desktop\Shortcut.url"
$targetpath = "https://yourwebsite.com"
$iconlocation = "c:\agent\yourico.ico"
$iconfile = "IconFile=" + $iconlocation