Windows PowerShell Cmdlets (Built-In)
On this page I define the word cmdlet to mean a built-in PowerShell command, with a single Verb-Noun pair. There is another shade of meaning to cmdlet, namely a series of commands, usually more than one line, stored in a text file with a .ps1 extension.
PowerShell Cmdlets Lists of the 13 Sections
- System Built-In Cmdlets
- Objects Built-In Cmdlets
- Items Built-In Cmdlets
- Aliases Built-In PowerShell Cmdlets
- Drives Built-In Cmdlets
- Paths and locations
- Contents Built-In PowerShell Cmdlets
- Access Operating System Components
- Output Formatters Built-In Cmdlets
- Variables
- Security Built-In Cmdlets
- Miscellaneous PowerShell Built-In Cmdlets
- Debugging
♣
PowerShell Build-In Cmdlet Categories
1) System Built-In PowerShell Cmdlets
a) Get-Help. This is the best command to explore the built-in PowerShell library. As with many cmdlets, it begins with the verb ‘get’. Example: Get-Help alias. Remember that Get-Help supports wildcards, for example type:
Get-Help *object.
b) Get-Command. Returns a list of available commands. Get-Command really is the entire command, I was expecting more, but this cmdlet is only two words, get and command separated by a hyphen. You may wish to try a wild card, for example Get-Command c*
c) Get-Host. Displays information about the PowerShell host. (Not to be confused with hostname.) Try this command to check your version number. $PSVersionTable
d) Get-Culture. Shows you information about the regional settings of the host (as defined in the Regional Settings of the Control Panel)
e) Get-UiCulture Returns information about the regional settings of the host as defined by the selected language on a multi-language operating system.
See more about key system cmdlets here »
2) Objects Built-In PowerShell Cmdlets
a) Get-Member. This is by far the most important cmdlet for research. Get-Member enumerates properties, methods and type information of the objects; for example:
Get-WmiObject | Get-Member
Special note, the pipeline symbol displays as ¦ in PowerShell, but as | in notepad. See a whole page on Get-Member
b) Foreach-Object. The purpose of this cmdlet is to loop through multiple instances, such as disk drives. Foreach applies a block of script to each object in the pipeline. For example;
$Nic= Get-WmiObject Win32_NetworkAdapterConfiguration
foreach ( $MacAdr in $Nic ) { "Mac Address = " + $MacAdr.MacAddress}
Note that the type of bracket is significant, () or {} each have a distinct role (condition) {script block}. Also note the + which not only adds numbers, but also is the same symbol that concatenates text.
c) Where-Object (Often abbreviated to plain ‘where’) filters the input from the pipeline, allowing operation on only certain objects. For example:
Get-Service | Where-Object {$_.status -eq "Stopped"}
d) New-Object. Creates instances of .NET or COM objects. New-Object is particularly useful for creating VBScript objects. For example, network objects, Active Directory objects and also applications such as IE.
e) Select-Object. Filters objects based on parameters set in the cmdlet command string
f) Group-Object. An undervalued cmdlet. Handy for collecting objects based on a common property value.
g) Sort-Object. Sequences object based on a property value
Guy Recommends: Free WMI Monitor for PowerShell
Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft’s operating systems. Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.
Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory, or Exchange Server. Give this WMI monitor a try – it’s free.
Download your free copy of WMI Monitor
3) Items Built-In Windows PowerShell Cmdlets
a) Get-Childitem Retrieves the child items of the specified location(s), for example a list files in a folder
b) Get-Item Returns an object that represents an item in a namespace, for example Get-Item .\* lists files in the current directory
c) New-Item Creates a new item in a namespace, for example creates a sub-folder
d) Set-Item Sets the value of a pathname within a provider to the specified value
e) Remove-Item Deletes an item from a provider
f) Move-Item Transfers an item from one location to another, removing the original
g) Rename-Item Changes the name of an existing item
h) Copy-Item Copies an item from one location to another, leaving the original intact
i) Clear-Item Removes the content of an item
j) invoke-Item Invokes an executable or opens a file
k) Get-Acl Gets the access control list (ACL) associated with a file or item
l) Set-Acl Sets the security ACL for an item or items
4) Aliases Built-In PowerShell Cmdlets
Understanding Aliases is easy. Just start with the built-in Aliases, for example gci (Get-Childitem). Also ft (format table) for example, Get-Process * |ft name, handles, cpu -auto
a) Set-Alias Maps an alias to a command, for example where you wish to create your own alias.
b) Get-Alias Returns a list of all defined aliases
c) New-Alias Creates a new alias
d) Export-Alias Outputs the system alias table in CSV format
e) Import-Alias Updates the system alias table from a CSV file
f) PowerShell 3 has 11 more aliases
Guy Recommends: A Free Trial of the Network Performance Monitor (NPM) v11.5
SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
Download a free trial of Solarwinds’ Network Performance Monitor
5) Drives Built-In Cmdlets
a) Get-PsDrive Returns a list of all drives registered with cmdlet providers
b) New-PsDrive Creates a new drive associated with a cmdlet provider
c) Get-PsProvider Returns a list of all registered cmdlet providers and the drives associated with each provider
d) Remove-Drive Removes a drive association from a cmdlet provider
6) List of Cmdlets Featuring Paths and Locations
a) Get-location Displays the current location
b) Set-Location Sets the current working location to a specified location. (It has the Alias CD)
c) Convert-Path Converts the path to the item given from an MSH path to a provider path
d) Parse-Path Given an MSH path(s), streams a string with the qualifier, parent path, or leaf item
e) Test-Path Returns true if the path exists, otherwise returns false
f) Resolve-Path Resolves the wildcards in a path
g) Push-Location Pushes a location to the stack
h) Pop-Pocation Changes the current working location to the location specified by the last entry pushed onto the stack
7) Contents Built-In PowerShell Cmdlets
a) Add-Content Appends content to a file or creates a file if one does not exist
b) Clear-Content Removes content from a file while leaving the file intact
c) Get-Content Returns the content of a file as a sequence of lines
d) Set-Content Replaces the content of a file with new content
Guy Recommends: SolarWinds’ Free Bulk Import Tool
Import users from a spreadsheet. Just provide a list of the users with their fields in the top row, and save as .csv file. Then launch this FREE utility and match your fields with AD’s attributes, click and import the users.
Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.
If you need more comprehensive application analysis software,
Download a free trial of SAM (Server & Application Monitor)
More PowerShell Cmdlets Lists
8) Access Operating System Components
a) Get-Process Returns a list of running system processes
b) Stop-Process Terminates a running process
c) Get-Service Returns a list of registered system services
d) Stop-Service Terminates a running system service
e) Start-Service Starts a stopped system service
f) Suspend-Service Pauses a running system service
g) Resume-Service Reactivates a paused system service
h) Restart-Service Stops then restarts a system service
i) Set-Service Configures the properties of a registered system service
j) New-Service Registers a new system service
k) Get-Eventlog Returns a list of event log entries from a specified event log
l) Get-WmiObject Returns data from WMI
®