Complete the code to display the current directory path in PowerShell on macOS.
Get-Location | Select-Object -ExpandProperty [1]The Path property of the object returned by Get-Location shows the current directory path as a string.
Complete the code to list all files in the current directory on macOS using PowerShell.
Get-ChildItem -File | [1] NameWhere-Object which filters items but does not select properties.Sort-Object which sorts but does not select properties.Select-Object Name selects and displays only the file names from the list of files.
Fix the error in the code to create a new directory named 'TestFolder' on macOS using PowerShell.
New-Item -ItemType Directory -Name [1]The -Name parameter expects the folder name as a string without quotes in PowerShell scripts. Quotes are optional but not required here.
Fill both blanks to filter files larger than 1MB and display their names in PowerShell on macOS.
Get-ChildItem -File | Where-Object { $_.[1] [2] 1MB } | Select-Object NameThe Length property gives the file size in bytes. Using > filters files larger than 1MB.
Fill all three blanks to create a hashtable of file names and their sizes for files modified in the last 7 days on macOS PowerShell.
$recentFiles = @(); foreach ([2] in (Get-ChildItem -File | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) })) { $recentFiles += @{ [1] = $[2].Name; [3] = $[2].Length } }
The variable item is used in the loop. The hashtable keys are Name and Size, and values come from item.Name and item.Length.