Skip to content

Fixes for files in chapter 03 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Chapter03/Listing 1 - Create Scheduled Task.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,4 +24,4 @@ $ScheduledTask = @{
Action = $Action
User = 'NT AUTHORITY\SYSTEM'
}
Register-ScheduledTask @ScheduledTask
Register-ScheduledTask @ScheduledTask
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 0 additions & 1 deletion Chapter03/Listing 4 - Watch-Folder.ps1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ foreach ($file in $sorted) {
break
}
}
}