2014/01/26

PowerShell Tip - Adding Help in the PARAM statement

It’s always a good idea to include help within your functions ! You never know who might benefit from it.

With PowerShell adding help to your script, function and module is a really easy thing to do.

Help in the PARAM statements


A very cool way to add some help to your script parameters is to add comments within the PARAM statement block. With this method you do not need to write a .PARAMETER directive for each paremeters. However you are required to write at least one directive in the Comment Based Help block (.SYNOPSIS or .DESCRIPTION) to be able to use it.

Example:

<#
    .SYNOPSIS
        This function will get some cool stuff
#>
    PARAM(
        # Specifies the computer name
        $ComputerName,
    
        # Specifies the Log directory Path
        $Logs = C:\lazywinadmin\logs
    )#PARAM

Then use Get-Help against your function/script

Get-Help Get-Something -Parameter *


This command will only return the Parameters information with the help we added in the PARAM statement

-ComputerName 
    Specifies the ComputerName

    Required?                    true
    Position?                    named
    Default value
    Accept pipeline input?       false
    Accept wildcard characters?  false


-Logs 
    Specifies the Log directory Path

    Required?                    false
    Position?                    named
    Default value                c:\lazywinadmin\logs
    Accept pipeline input?       false
    Accept wildcard characters?  false




Even if this tip is pretty cool, I would still recommend to use the Comment Based Help block to have a centralized place to put all the help !


Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.

2014/01/25

PowerShell ISE Tip - Navigate between curly brackets

While playing with PowerShell ISE today, I just found out about this little nice trick to navigate between brackets !!! I did not know about this! Pretty cool stuff ! :-)



By positioning your cursor on one of the brackets, you can navigate to its opening/closing one by pressing CTRL +  ]


Update: Looks like you can actually do the same thing with SAPIEN PowerShell Studio 2012

Update#2: The matching actually works for anything the ISE recognizes as a matched pair, for example, () and [] in addition to {}. Unfortunately matching doesn't seem to work inside herestrings and other comments. (Thanks Greg Wojan)

PowerShell ISE - Navigate between brackets using CTRL + }



That's just Awesome !!! :-)


Here is an example using SAPIEN PowerShell Studio 2012



Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.

2014/01/16

Winter Scripting Games 2014

Get Ready! The Winter Scripting Games 2014 are starting very soon !! The Event 1 is scheduled to start this week-end (Jan 19th 2014)! The Games are an amazing opportunity to learn more about PowerShell. This is the kind of thing you don't want to miss !!! 

Last year I jumped in for the first time in the 2013 edition and this was really a lot of fun !!! It gave me a huge boost to my PowerShell Skills and so much more confidence in my scripting style !!! You can refer to my old blog posts for each Scripting Games 2013 events were I tried to analyze each of my solutions.



Back at the beginning of December I was actually offered by +Mike Robbins to Coach the teams, but since I had so much fun playing at the last games I decided to play again this year, couldn't resist!!

For the 2014 Edition however, the formula of the Scripting Games is a bit different:
  • Teams: This edition of the Scripting Games is a team work event ! No more Solo mode, participants have to create or join a team (from 2 to a maximum of 6 team members),
  • Coaches: A list of experts will give advices/critics on the posted script via comments or blog posts.
  • Judges: A team of MVPs and Well-known PowerShell Guru will scores each of the scripts.

2014/01/12

PowerShell MVP award

Here a quick post to show you the awesome MVP Welcome Kit I received ! :-)





Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.

2014/01/10

I'm a PowerShell Hero ! Thank you guys !

Wow ! What a year so far... I'm one of the five persons who received the first-ever PowerShell Heroes recognition on PowerShell.org.

"The idea was to offer a kudos to folks who have been working hard in the PowerShell community, but who haven’t received other formal recognition (like Microsoft’s MVP Award)."

First, I was really surprised to receive this recognition ! I recently got my first MVP award on the 1st of January 2014 and I immediately contacted +Don Jones to let him know there was a conflict. However he said this was related to my work done in the past year(s) and they decided to recognize me anyway.

Second, I want to say THANK YOU for those who recommended me. I am very humbled and honored that my contributions to this community are helpful to some people out there ! So again THANK YOU!!! MERCI!!!

2014/01/05

Microsoft MVP 2014 for PowerShell !

What an amazing way to start the year !!! It is a great pleasure and honor to announce that on the 1st of January I was awarded the Microsoft Most Valuable Professional (MVP) Award for outstanding contributions in Windows PowerShell.

Dear Francois-Xavier Cat, 
Congratulations! We are pleased to present you with the 2014 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in PowerShell technical communities during the past year.
I would like to take this opportunity to thank especially Vivian for her support and motivation, Simran and Joel from Microsoft Canada (who first contacted me back in September), Andrey from Domtar and Jean-Philippe from Akilon.

I was able to get to this point today thanks to the great content created by the PowerShell Community.
Just to name a  few people I follow: Ed Wilson (The Scripting Guy), +Ravikanth Chaganti , +Boe Prox , +Jeffery Hicks , +Aleksandar Nikolic , +Lee Holmes , +Brandon Shell , +Don Jones , ...

Here is my Microsoft MVP Profile: http://mvp.microsoft.com/en-us/mvp/Francois-Xavier%20Cat-5000475


Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page

2014/01/01

Top Five 2013 LazyWinAdmin Blog Posts

The year 2013 has been a pretty good year for the LazyWinAdmin blog.
Thank you guys for following my blog and participating to the comments discussions. Thanks also for those who give me advices, critics and ideas to improve my scripts, I think It helps everyone (and myself) to improve our knowledge everyday, Really appreciated :-)

I get more and more page views, comments,... every month  :-) and I thought It would be nice to give a small Top Five 2013 of the LazyWinAdmin blog posts.



Top Five 2013 Blog posts:


WS2012 Storage - NFS Server - Configure NFS for VMware vSphere 5.1 Home Lab
This article focus on how to configure NFS on Windows Server 2012 with PowerShell for a VMware vSphere 5.1 host.


PowerShell Studio 2012 - WinForms - Creating a basic GUI (Video) 
This is a quick tutorial (with a video) on how to create a really basic Winform/Graphical User Interface (GUI) using SAPIEN PowerShell Studio 2012.


PowerShell - Monitor and Report Active Directory Group Membership Change
This is probably one of my most popular script. This PowerShell script let you monitor membership of one or multiple groups. You can specify the names of the group(s) directly, from a file or from an OU path.

PowerShell - Get a SubString out of a String using RegEx 
In 2013 I started playing a bit more with Regex, this post talked about getting text from a string. I'll post more about this subject soon.

PowerShell 4.0 is now available
The team of Jeffery Snover, the PowerShell Team,  realeased a new version of this awesome tool ! more cmdlets!! more fun!!



Thanks for reading! If you have any questions, leave a comment or send me an email at fxcat@lazywinadmin.com. I invite you to follow me on Twitter @lazywinadm / Google+ / LinkedIn. You can also follow the LazyWinAdmin Blog on Facebook Page and Google+ Page.