From c05a002f3e9336eec5b77da5e32f69a2850468d2 Mon Sep 17 00:00:00 2001 From: Gonzalo Huerta-Canepa Date: Tue, 12 Apr 2022 10:49:22 -0400 Subject: [PATCH 1/3] Update Listing 3 - Importing Multiple a Scheduled Tasks.ps1 Fixing variable in loop for TaskFiles --- .../Listing 3 - Importing Multiple a Scheduled Tasks.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Chapter03/Listing 3 - Importing Multiple a Scheduled Tasks.ps1 b/Chapter03/Listing 3 - Importing Multiple a Scheduled Tasks.ps1 index 6de2df4..076d405 100644 --- a/Chapter03/Listing 3 - Importing Multiple a Scheduled Tasks.ps1 +++ b/Chapter03/Listing 3 - Importing Multiple a Scheduled Tasks.ps1 @@ -4,9 +4,9 @@ $Share = "\\srv01\PoSHAutomation\" $TaskFiles = Get-ChildItem -Path $Share -Filter "*.xml" # parse through each file and import the job -foreach($task in $TaskFiles){ +foreach($FilePath in $TaskFiles){ $xml = Get-Content $FilePath -Raw [xml]$xmlObject = $xml $TaskName = $xmlObject.Task.RegistrationInfo.URI Register-ScheduledTask -Xml $xml -TaskName $TaskName -} \ No newline at end of file +} From eb87e90261b365396a73a15930981bc35bdf5119 Mon Sep 17 00:00:00 2001 From: Gonzalo Huerta-Canepa Date: Tue, 12 Apr 2022 10:50:06 -0400 Subject: [PATCH 2/3] Update Listing 4 - Watch-Folder.ps1.ps1 Removing extra parenthesis --- Chapter03/Listing 4 - Watch-Folder.ps1.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/Chapter03/Listing 4 - Watch-Folder.ps1.ps1 b/Chapter03/Listing 4 - Watch-Folder.ps1.ps1 index 29b0e62..3377c2b 100644 --- a/Chapter03/Listing 4 - Watch-Folder.ps1.ps1 +++ b/Chapter03/Listing 4 - Watch-Folder.ps1.ps1 @@ -81,4 +81,3 @@ foreach ($file in $sorted) { break } } -} \ No newline at end of file From 7ec187b97892475001b0e051ccf4a4de8fe809ca Mon Sep 17 00:00:00 2001 From: Gonzalo Huerta-Canepa Date: Tue, 12 Apr 2022 10:51:06 -0400 Subject: [PATCH 3/3] Update Listing 1 - Create Scheduled Task.ps1 Removing closing backslashes on path --- Chapter03/Listing 1 - Create Scheduled Task.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Chapter03/Listing 1 - Create Scheduled Task.ps1 b/Chapter03/Listing 1 - Create Scheduled Task.ps1 index a2bd05f..0100a54 100644 --- a/Chapter03/Listing 1 - Create Scheduled Task.ps1 +++ b/Chapter03/Listing 1 - Create Scheduled Task.ps1 @@ -7,7 +7,7 @@ $Execute = "C:\Program Files\PowerShell\7\pwsh.exe" # Set Action arguments $Argument = '-File ' + '"C:\Scripts\Invoke-LogFileCleanup.ps1"' + - ' -LogPath "L:\Logs\" -ZipPath "L:\Archives\"' + + ' -LogPath "L:\Logs" -ZipPath "L:\Archives"' + ' -ZipPrefix "LogArchive-" -NumberOfDays 30' # Create the Scheduled Task Action @@ -24,4 +24,4 @@ $ScheduledTask = @{ Action = $Action User = 'NT AUTHORITY\SYSTEM' } -Register-ScheduledTask @ScheduledTask \ No newline at end of file +Register-ScheduledTask @ScheduledTask