A beginners guide to Powershell - Part 2 - Getting started with Powershell ISEsteemCreated with Sketch.

in #technology7 years ago (edited)

Hi fellow Steemians,

in this second part of "A beginners guide to Powershell" (Part 1 - Introduction) I want to introduce you to the Powershell Integrated Scripting Environment (short ISE) in a little more depth. 


After starting ISE (covered in Part 1) you should see this:

For simplicity I have marked the most relevant areas:

  1. This is the Editor pane, here you write your script
  2. This is an interactive powershell console, you can execute commands to your liking (Enter command and press Enter). If you execute code from the Editor pane it will be executed in this console
  3. Commands overview, in this pane you can see all cmdlets (commands) of all Powershell Modules that are installed on your PC. There are Modules for a lot of different technologies like Exchange, Sharepoint, Office365 and many more
  4. The Run/Stop Button, from left to right: 
  • Run Script (F5) - Executes all code in the Editor pane
  • Run Selection (F8) - Executes marked code
  • Stop Operation (Ctrl+C) - Stops Execution


Powershell Commands

In powershell commands are generally called cmdlets, the naming convention for Powershell is Verb-Noun. There are certain proposed verbs for certain functions like "Get" for getting information, "Set" for changing information etc. the list of approved verbs can be found here.

This naming convention makes powershell a very readable language since you will end up with simple to understand command names like Get-Item, Set-Item, Move-Item . The Noun part of the cmdlets is supposed to be descriptive as well of course, which sometimes leads to ridiculously long command names like Get-AzureRmRecoveryServicesAsrStorageClassificationMapping. Apart from that the naming system is pretty good and allows for easy exploration.


Exploring the Shell

Powershell is a very explorable language, using some basic commands you can find out what commands are available on your system, what they do and how you can use them.

As you might have extracted from my previous writing powershell commands are seperated into different modules so you might find network-related commands in one module and commands for file interaction in another one.


You can find out what modules are installed on your PC with the following command (Enter in the interactive console):

Get-Module -ListAvailable

Remember that you can use tab completion. Also the console is case insensitive by default so you can just go off in all lowercase (or caps if that´s your thing ;))


You can also search for commands directly:

Get-Command

by default this lists all commands of all available modules, if you want to see commands of a specific module you can use the Module parameter:

Get-Command -Module smbshare

or you can just search all commands that have a certain flag in them like for example SMB:

Get-Command *smb*

The asterisk acts as a wildcard.


Getting help

So now you found a command you are interested in but you still dont know what it does or how it works? No problem, getting help in powershell is as easy as this (Set-Item as example):

Get-Help Set-Item

This will give you a short overview over the command, including available parameters and Syntax.

For the complete information you can enter

Get-Help Set-Item -Full

or

Get-Help Set-Item -Online

The -Online switch opens a new tab in your web browser so you can read the help in a familiar environment.


Up next

In the next part of the series I will probably go deeper into using commands, variables and some basic comparison operators. 

If you have questions or suggestions related or unrelated to this series feel free to contact me.



Sort:  

it seems silly question.... but, what the difference between powershell & command prompt ????

waiting your next tutorial........

Hi budinurdin,
thanks for the question, there are quite a few.

The baseline is:
You can do practically everything in powershell that you can already do in the command prompt, but better. In addition to being a shell powershell is also an object oriented scripting language, which makes output processing a lot easier and non localized. There are a lot more prebuilt commands and most Microsoft Products (and some other) have their own modules for administration.

Also, as you will see in the upcoming parts, powershell is a very elegant language which allows you to do fairly complex task with even a single line of code.

And a few dozen other things like builtin remoting, easy access to WMI, CIM, COM, multithreading etc.
It is too much for one post and a lot of things are out of scope for the beginners series but i hope that gives you an impression.

Regards

Coin Marketplace

STEEM 0.19
TRX 0.24
JST 0.037
BTC 97079.51
ETH 3326.73
USDT 1.00
SBD 3.09