From 6aa57ebf7183cbd72b006ea41d66d2f4bae94fc5 Mon Sep 17 00:00:00 2001 From: bschaper Date: Mon, 27 Jan 2025 14:47:28 -0600 Subject: [PATCH] Added ps1 System Tasks --- Tasks/Run-System-Tasks.ps1 | 19 +++++++++++++------ Tasks/System-Tasks/Check-Repair-Printers.bat | 2 -- .../Check-Repair-Printers.ps1 | 0 3 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 Tasks/System-Tasks/Check-Repair-Printers.bat rename Tasks/{ => System-Tasks}/Check-Repair-Printers.ps1 (100%) diff --git a/Tasks/Run-System-Tasks.ps1 b/Tasks/Run-System-Tasks.ps1 index c0ecd91..02b3928 100644 --- a/Tasks/Run-System-Tasks.ps1 +++ b/Tasks/Run-System-Tasks.ps1 @@ -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)" } -} \ No newline at end of file +} diff --git a/Tasks/System-Tasks/Check-Repair-Printers.bat b/Tasks/System-Tasks/Check-Repair-Printers.bat deleted file mode 100644 index 6aa910c..0000000 --- a/Tasks/System-Tasks/Check-Repair-Printers.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -powershell.exe -ExecutionPolicy Bypass -File "c:\scripts\Tasks\Check-Repair-Printers.ps1" diff --git a/Tasks/Check-Repair-Printers.ps1 b/Tasks/System-Tasks/Check-Repair-Printers.ps1 similarity index 100% rename from Tasks/Check-Repair-Printers.ps1 rename to Tasks/System-Tasks/Check-Repair-Printers.ps1