Share via


PowerShell 3.0 - Shell from Future

PowerShell 3.0 is shipped with Windows 8. We are still experiencing some of the great features of Windows Server 8, but PowerShell 3.0 also brings many new features. Thanks to PowerShell Product Team for such a great innovation.

In this blog post, I will discuss about some of simplified syntaxes.

PowerShell Integrated Script Environment has an improved UI design and features.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4503.clip_5F00_image002_5F00_thumb_5F00_79E73A99.jpg

This is new designed PowerShell ISE console.

Right pane you’ll notice Commands section.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/8284.clip_5F00_image004_5F00_thumb_5F00_6B5C18A7.jpg

As you know, in PowerShell V2 you have to query available commands or syntax with get-help or Tab button.

In PowerShell 3.0 you can search any kind of command within Commands pane. I searched for commands that includes “printer” and it outputs all available commands.

And also it provides me all required or optional parameters for selected command.

Now i can select Get-Printer cmdlet and fill up mandatory or optional params.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/2425.clip_5F00_image006_5F00_thumb_5F00_07A95AC8.jpg

Now just click copy and paste into script pane.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/3808.clip_5F00_image008_5F00_thumb_5F00_6F5640AC.jpg

This is a great feature especially for those who don’t like much writing or remembering script syntax.

Another great feature is improved Tab button http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4555.wlEmoticon_2D00_smile_5F00_22B20409.png Now it completes automatically for all kind of parameter, argument etc. within a window.

In below example, I just write Get-Pro and press tab. It brings all available commands that start with Get-Pro

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/7776.clip_5F00_image010_5F00_thumb_5F00_6711F548.jpg

It also brings parameters and arguments.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/2480.clip_5F00_image012_5F00_thumb_5F00_0E88C1B3.jpg

And finally it gets to you all available processes on your system lively !

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4628.clip_5F00_image013_5F00_thumb_5F00_71BF26D0.png

Another example of argument auto completion:

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/6685.clip_5F00_image014_5F00_thumb_5F00_22FDEB64.png

Auto completion also works for .Net. If you call [System.Net.DNS] it will bring you all available methods.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/0081.clip_5F00_image016_5F00_thumb_5F00_3F4B2D84.jpg

Error notification is also available lively.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/3108.clip_5F00_image017_5F00_thumb_5F00_600EF06B.png

I think one of the greatest features of PowerShell 3.0 is statement help.

If you press CTRL + J, it will bring you all statements with their usage and examples.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4188.clip_5F00_image019_5F00_thumb_5F00_7132A841.jpg

But this is not enough.

Just click one of the statements and then it will paste a template usage example into your Script Pane.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/7713.clip_5F00_image020_5F00_thumb_5F00_4DB603DC.png

This is a great feature cause I believe many system administrators don’t want to remember usage of each statement. They don’t need any more.

With PowerShell 3.0, you don’t need special $_. Character to filter script outputs.

Below is a simple example in PowerShell 2.0 to get a process that has a name “IDLE”. For complex scripts it is open for mistakes.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/4667.clip_5F00_image021_5F00_thumb_5F00_3BA9C04F.png

In PowerShell 3.0 just put a pipe and write only column name with no special character. It works and looks great.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/5238.clip_5F00_image022_5F00_thumb_5F00_6C101EF8.png

It’s same for foreach too.

http://blogs.technet.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-79-57-metablogapi/6712.clip_5F00_image023_5F00_thumb_5F00_41080B26.png

This is a brief post about PowerShell 3.0 features. There are bunch of great features and we will figure out them in our next blogs.

See Also