Basic Powershell commands

On this page some simple but useful Powershell commands are shown. These commands are the basics of the usage of Powershell.

To search all Powershell cmdlets for a keyword the ‘Get-Command’ command can be used. The ‘Get-Command’ can be abbreviated to ‘gcm’. To search for all commands that contain the word ‘network’ you can use the following commands.

gcm

Get-Command

It is also possible to serach within a specific module. To search in the NetTCPIP module the following command can be used:

Module

If you need to know more about a specific cmdlets you can use the ‘Get-Help’ command followed by the command you want to have more information about.

Get-Help

If you want to know the details of an cmdlet the ‘Get-Member’ command can be used. If you for example want to know what information can be shown with the ‘Get-Process’ command the following command can be used:

Get-Member

Within an output you can search for a specific value. To search for specific values you can use the ‘Where-Oject’ command. In this example we search for all processes named MMC.

Where-Object

The first thing the code is doing is getting a list of processes on our computer and passing the output (using the | character) to our Where-Object cmdlet. The cmdlet takes a script block as a parameter. The script block instructs the Where-Object cmdlets to only select objects where their name parameter is equal to ‘mmc’. The result is a list of the MMC instances that are running.

To stop all the instances of MMC that are running you can pipe the output to a ‘Stop-Process’ command.

Stop-Process

Delen via: Facebooktwitterpinterestlinkedinmail