Complete the code to get the current user's home directory in PowerShell.
Write-Output $[1]In PowerShell, the current user's home directory is stored in the environment variable USERPROFILE. Access it using $env:USERPROFILE.
Complete the code to check if the current OS is Windows in PowerShell.
if ($PSVersionTable.OS -[1] 'Windows') { Write-Output 'Windows OS' }
The -match operator performs a regex match. Since $PSVersionTable.OS contains a string with OS info, -match 'Windows' checks if 'Windows' is part of that string.
Fix the error in the code to list all files in the current directory on Linux using PowerShell.
Get-ChildItem -Path . | Where-Object { $_.[1] -eq $false }The property PSIsContainer is $true for directories and $false for files. To list files, check where PSIsContainer is $false.
Fill both blanks to create a dictionary of file names and sizes for files larger than 1MB in the current directory.
$files = @{ } ; Get-ChildItem -File | Where-Object { $_.Length [1] 1MB } | ForEach-Object { $files[[2]] = $_.Length }Use > to filter files larger than 1MB. Use Name as the key in the dictionary to store file sizes.
Fill all three blanks to create a list of process names running with more than 100 MB memory usage.
$heavyProcs = Get-Process | Where-Object { $_.[1] [2] 100MB } | Select-Object -ExpandProperty [3]WorkingSet64 gives memory usage in bytes. Use > to filter processes using more than 100MB. Select the ProcessName property to get the names.