Powershell Core 6.2 Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

Let's perform the following steps:

  1. On Windows, run pwsh.exe. On Linux or macOS, run pwsh.
  2. Type your first cmdlet, Get-Process, to retrieve a list of running processes on the system and hit Enter to confirm.
  3. Compare the output of the cmdlet with the output of tasklist (in Windows) and ps (in Linux):
  1. Type Get-Date and hit Enter to confirm.
  1. Compare the output of this cmdlet with the output of date /t (in Windows) and date (in Linux):
  1. Execute the line: Get-Process | Where-Object -Property WorkingSet -gt 100MB.
  2. Compare the output again with the output of tasklist /FI "MEMUSAGE gt 102400" (in Windows) and ps -aux | awk -F" " '$5 > 102400' (in Linux):
  1. Lastly, execute this cmdlet: Stop-Computer -WhatIf. This time, there's no comparable command on either Windows or Linux.