2
0

Added ps1 System Tasks

This commit is contained in:
bschaper 2025-01-27 14:47:28 -06:00
parent edd0d7512a
commit 6aa57ebf71
3 changed files with 13 additions and 8 deletions

View File

@ -1,19 +1,26 @@
# Specify the directory containing the scripts
$scriptDirectory = "C:\Scripts\Tasks\System-Tasks"
# Get all Batch scripts in the directory
# Get all Batch and PowerShell scripts in the directory
$scriptsToRun = Get-ChildItem -Path $scriptDirectory -Filter "*.bat"
$psScripts = Get-ChildItem -Path $scriptDirectory -Filter "*.ps1"
$scriptsToRun += $psScripts
# Iterate through the script paths and execute each one
foreach ($script in $scriptsToRun) {
try {
# Execute the script
& "$($script.FullName)"
# Execute the script based on its extension
if ($script.Extension -eq ".ps1") {
# Execute PowerShell script
& "$($script.FullName)"
} else {
# Execute Batch script
& "$($script.FullName)"
}
# Add a delay or other actions between scripts if needed
Write-Host "Script '$script' executed successfully."
Start-Sleep -Seconds 5 # Adjust the delay as needed
} catch {
Write-Warning "Error executing '$script' $($_.Exception.Message)"
Write-Warning "Error executing '$script': $($_.Exception.Message)"
}
}

View File

@ -1,2 +0,0 @@
@echo off
powershell.exe -ExecutionPolicy Bypass -File "c:\scripts\Tasks\Check-Repair-Printers.ps1"