|
Guy recommends :
Find out which of your VMs are a waste of space and which VMs need more resources.
|
PowerShell Tutorial - Three Key CommandsIntroduction to Key PowerShell CommandsHere are three simple, yet key commands, which are designed to get you started with PowerShell. As you study, my example scripts keep in mind the golden rule, verb-noun, for example, Get-PSProvider. Three Key PowerShell Commands or Cmdlets♣ 1. PowerShell Get-CommandLet us begin this PowerShell scripting tutorial by testing Get-Command. What this instruction does is list all of PowerShell's noun-verb pairs; incidentally, these are also referred to as built-in cmdlets. Assuming that you have opened a PowerShell session, then you should see a prompt like: PS > Now type just one hyphenated phrase: # Windows PowerShell Tutorial To filter the list, employ the famous star * wildcard; here are three examples:
Let us experiment with a variation of this wildcard theme which
displays only cmdlets beginning with the verb 'set': It is possible to tweak the display of your output columns with ft (Format-Table). My hidden agenda here is to give you practice with PowerShell's Pipe symbol (|), try: #PowerShell Scripting Tutorial At the moment we are just 'playing', testing, or feeling our way, thus do feel free to experiment with your own variations of my suggestions. Once you have seen the long list of all possible commands, chose one cmdlet for further research, for example: Refine Get-Command with -CommandType # PowerShell WhatIf cmdlets Get-PSProvider (Or plain: PSProvider) This is what happened when I typed just: Get-Psprovider <carriage return> Name Capabilities Drives Challenge: try Another Command PSSnapin What PSSnapin does is reveal the sources for the built-in cmdlets: Clear-Host Note how every PowerShell noun is singular, PSSnapin, Command, PSProvider. Also note how a Pipe (|) followed by ft means format the output as a table, as opposed to format the results as a list (fl). Any words which follow 'ft' are names of the fields, each separated by a comma. At the end of the above command is the switch -autosize, this extra parameter tells PowerShell to close-up the width of the columns. When ever you use format-Table, or ft, try appending -autosize, or the shorter version: -auto. In the example below, I have used ft to omit the Description field and just displayed the name: Name
Guy
Recommends: WMI Monitor and It's Free!
|