Complete the code to display the current date and time.
Get-Date | [1]Out-File writes to a file, not the screen.Start-Process starts a new process, not output.Get-Content reads from a file, not output.The Write-Output cmdlet sends the current date and time to the console, showing it immediately.
Complete the code to create a folder named 'Reports'.
New-Item -Path . -Name 'Reports' -ItemType [1]
File creates a file, not a folder.Text is not a valid item type here.Process is unrelated to creating folders.The Directory type tells PowerShell to create a folder, which saves time by automating folder creation.
Fix the error in the script to list all files in the current directory.
Get-ChildItem [1]-Folder lists folders, not files.-Process is invalid here.-Content is not a valid parameter for this cmdlet.The -File parameter lists only files, which helps automate file management tasks efficiently.
Fill both blanks to create a loop that prints numbers 1 to 5.
for ($i = [1]; $i [2] 5; $i++) { Write-Output $i }
Start the loop at 1 and continue while $i is less than or equal to 5 to print numbers 1 through 5.
Fill all three blanks to create a hashtable of file sizes for '.txt' files.
$sizes = @{}; foreach ([3] in Get-ChildItem -Filter '*.txt') { $sizes[[1]] = [2].Length }This creates a hashtable where each key is the file name and the value is the file size, automating file size collection.