0
0
PowerShellscripting~5 mins

Log cleanup automation in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of log cleanup automation?
To automatically delete or archive old log files to save disk space and keep the system organized.
Click to reveal answer
beginner
In PowerShell, which cmdlet is commonly used to remove files?
The <code>Remove-Item</code> cmdlet is used to delete files or folders.
Click to reveal answer
intermediate
How can you find files older than 30 days in PowerShell?
Use Get-ChildItem with Where-Object to filter files by their LastWriteTime property, like: Get-ChildItem | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) }.
Click to reveal answer
beginner
Why is it important to test a log cleanup script before scheduling it?
To make sure it deletes only the intended files and does not remove important data by mistake.
Click to reveal answer
beginner
What PowerShell feature allows you to schedule a script to run regularly?
You can use Windows Task Scheduler to run PowerShell scripts on a schedule.
Click to reveal answer
Which PowerShell cmdlet deletes files?
ASet-Location
BGet-Content
CRemove-Item
DNew-Item
How do you select files older than 7 days in PowerShell?
AWhere-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-7) }
BWhere-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) }
CGet-ChildItem -OlderThan 7
DRemove-Item -OlderThan 7
What is a safe first step before deleting files with a script?
ADelete all files immediately
BRun the script as administrator without testing
CIgnore file dates
DRun the script with <code>-WhatIf</code> to simulate deletion
Which tool schedules PowerShell scripts to run automatically?
AWindows Task Scheduler
BPowerShell ISE
CNotepad
DFile Explorer
What does Get-ChildItem do in PowerShell?
AChanges file permissions
BLists files and folders in a directory
CCreates new files
DDeletes files
Explain how to create a PowerShell script that deletes log files older than 30 days.
Think about listing, filtering, deleting, and testing steps.
You got /4 concepts.
    Describe how to schedule a PowerShell log cleanup script to run every week.
    Focus on scheduling steps using Windows tools.
    You got /5 concepts.