2
0
tcse-deploy/Patches/Tasks/System_Tasks.ps1

19 lines
657 B
PowerShell

# Specify the directory containing the scripts
$scriptDirectory = "C:\Scripts\Login\System_Tasks"
# Get all Batch scripts in the directory
$scriptsToRun = Get-ChildItem -Path $scriptDirectory -Filter "*.bat"
# Iterate through the script paths and execute each one
foreach ($script in $scriptsToRun) {
try {
# Execute the 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)"
}
}