• Register the "OneCode & OneScript" session at MVP Global Summit November 2013

    The yearly Microsoft MVP Global Summit will lift its curtain on Nov 17th in Bellevue, WA.  This year, we have prepared three new apps and many new samples in response to MVPs’ feedbacks last year.  If you are attending this year’s Microsoft MVP Global Summit, you will have the privilege to kiss or bite their development team Smile 

    • Sample Browser Windows Phone app – with 6000+ MSDN code samples which will be at your fingertips anytime and anywhere.
    • Script Explorer for PowerShell ISE – with 8000+ script sample which will be at your fingertips when you are writing scripts in PowerShell ISE.
    • PowerShell checkin policy for TFS – automatically checks your PowerShell script code against best practices of PowerShell.

     

    Interested?  Please open your Schedule Builder for the MVP Summit 2013, and register for the event called “OneCode & OneScript” on Nov 17th.  We look forward to seeing you and learning your feedback.

     

    image

  • Releasing Script Browser & Script Analyzer for Windows PowerShell ISE

    Here we'd like to share a piece of good news with everybody:  today we have a new app released – Script Browser for Windows PowerShell ISE.

    Script Browser for Windows PowerShell ISE was designed and developed in response to many IT Pros’ and MVPs’ feedback during the MVP Global Summit.  It puts nearly 10K script examples at IT Pros fingertips when they write scripts to automate their IT tasks. Users can search, learn, download and manage scripts from within their scripting environment - PowerShell ISE - with just a few button clicks.  It saves the time of switching back and forth between webpages and scripting environment, and also the trouble of countless download, copy, and paste operations.  Bundled with Script Browser is another neat feature called ‘Script Analyzer’ that automatically analyzes user’s script against 7 PowerShell best practices, and suggests improvements. Click here to get it now and share the announcements from the Windows PowerShell product team with your IT friends to make their work easier.

    Getting started with Script Browser 1.0


    It is very essential that an app satisfies users’ requirements. Therefore, feedback is of prime importance. For Script Browser, MVPs are one of the key sources where we get constructive feedback. When the Script Browser was demoed at the 2013 MVP Global Summit in November, 2014 Japan MVP Open Day, and a Product Group Interaction event, the MVP community proposed insightful improvements. For instance, MVPs suggested showing a script preview before users can decide to download the complete script package. MVPs also wanted to be able to search for script samples offline. These were great suggestions, and the team immediately added the features to the release. We have collected a pool of great ideas (e.g. MVPs also suggested that the Best Practice rules checking feature in Script Analyzer should be extensible). We are committed to continuously improving the app based on your feedback.

    We have an ambitious roadmap for Script Browser. For example, we plan to add more script repositories to the search scope. We are investigating integration with Bing Code Search. We are also trying to improve the extensibility of Script Analyzer rules. Some features, like script sample sharing and searching within an enterprise, are still in their infancy.

    We sincerely suggest you give Script Browser a try (click here to download). If you love what you see in Script Browser, please recommend it to your friends and colleagues. If you encounter any problems or have any suggestions for us, please contact us at onescript@microsoft.com.  Your precious opinions and comments are more than welcome.

     

     

    Acknowledgement

    Individually, we are one drop. Together, we are an ocean.  The v1 release of Script Browser is a big collaborative effort from many teams at Microsoft.   Mei Liang, Dan Ruder, Jialiang Ge, Bill Grauer, Allen Ding, Allen Li, Huajun Gu (MVP), Qi Fu from Microsoft CSS worked with the PowerShell Product Group represented by John Slack (PM), Frederic Francois, Samuel Li, Susan Mings, Vlad Carpenco, and Kriti Jindal, and the TechNet Script Center team represented by Bryant Hawthorne.  Pei Wang and Satoru Kitabata localized the app to 14 languages.  Microsoft GARAGE (Ben Gilbert is the PM) provides a perfect platform to demonstrate the app and internally crowd-source ideas and effort to make it better. Nearly 20 Microsoft Garage volunteers, and even their wifes, contributed test and localization to the release: Michael Janelle-Montcalm, Tiago Damasceno, Leland Holmquest's wife Geylan Holmquest, Petr Rybak, Igor Rybak, Piotr Walaszek, Cale Teeter's wife, Jose Cardenas Salazar, Aldo Mendoza Saucedo, Damian Leibaschoff (PSS), Markus Jansen, Tim Sullivan, Jorge Aleman Rodriguez, Ronald Aigner, Roberto Aldaba Mendez, Raffaele Limosani, Christian Kuhtz, Eric Chang (MSR), Erik Millan Jimenez, Tino Morenz.

  • Here Comes the Update of Script Browser & Script Analyzer 1.1

    Update: Version 1.2 of the Script Browser is out.  Check out the announcement here: http://blogs.technet.com/b/onescript/archive/2014/05/11/what-s-new-in-script-browser-amp-script-analyzer-1-2.aspx

     

    The Script Browser for Windows PowerShell ISEhas received thousands of downloads since it was released a week ago. Based on your feedbacks, today we release the 1.1 update to respond to the highly needed features. The team is committed to making the Script Browser and Script Analyzer useful. Your feedback is very important to us.

    Download Script Browser & Script Analyzer 1.1 
    (If you have already installed the 1.0 version, you will get an update notification when you launch Windows PowerShell ISE.)

     

    1. Options to Turn on / Turn off Script Analyzer Rules

    You can either select to turn on or turn off the rules in the Settings window of Script Analyzer.

    image

    You can also suggest a new Script Analyzer rule or vote for others’ suggestions. Our team monitors the forum closely. Based on your suggestions and votes, we will provide the corresponding Script Analyzer rules in future updates. We are also looking into the capability for you to write your own Script Analyzer rules and plug into the Script Analyzer.

     

    2. Refined Script Analyzer Rules with Detailed Description

    Thanks to your feedback, we refined the Script Analyzer rules that were released in the version 1.0. We also fixed all rule issues that you reported. Each rule comes with a detailed description, good/bad examples, and supporting documents. Here are the 5 refined rules released in this update. We look forward to learning your feedback.

    Invoke-Expression use should be carefully considered

    Invoke-Expression is a powerful command; it’s useful under specific circumstances but can open the door for malicious code being injected. This command should be used judiciously.

    http://blogs.msdn.com/b/powershell/archive/2006/11/23/protecting-against-malicious-code-injection.aspx

    Cmdlet alias use should be avoided

    Powershell is a wonderfully efficient scripting language, allowing an administrator to accomplish a lot of work with little input or effort. However, we recommend you to use full Cmdlet names instead of alias' when writing scripts that will potentially need to be maintained over time, either by the original author or another Powershell scripter. Using Alias' may cause problems related to the following aspects:

    Readability, understandability and availability. Take the following Powershell command for an example:

    Ls | ? {$_.psiscontainer} | % {"{0}`t{1}" -f $_.name, $_.lastaccesstime}

    The above syntax is not very clear to the novice Powershell scripter, making it hard to read and understand.

    The same command with the full Cmdlet names is easier to read and understand.

    Get-ChildItem | Where-Object {$_.psiscontainer} | ForEach-Object {"{0}`t{1}" -f $_.name, $_.lastaccesstime

    Lastly, we can guarantee that an alias will exist in all environments.

    For more information, please see the linked Scripting Guy blog on this topic.

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/21/when-you-should-use-powershell-aliases.aspx

    Empty catch blocks should be avoided

    Empty catch blocks are considered poor design decisions because if an error occurs in the try block, the error will be simply swallowed and not acted upon. Although this does not inherently lead to undesirable results, the chances are still out there. Therefore, empty catch blocks should be avoided if possible.

    Take the following code for an example:

    try
    {
            $SomeStuff = Get-SomeNonExistentStuff
    }
    catch
    {
    }

    If we execute this code in Powershell, no visible error messages will be presented alerting us to the fact that the call to Get-SomeNonExistentStuff fails.

    A possible solution:

    try
    {
             $SomeStuff = Get-SomeNonExistentStuff
    }
    catch
    {
            "Something happened calling Get-SomeNonExistentStuff"
    }

    For further insights:

    http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/11/hey-scripting-guy-march-11-2010.aspx

    Positional arguments should be avoided

    Readability and clarity should be the goal of any script we expect to maintain over time. When calling a command that takes parameters, where possible consider using Named parameters as opposed to Positional parameters.

    Take the following command, calling an Azure Powershell cmdlet with 3 Positional parameters, for an example:

    Set-AzureAclConfig "10.0.0.0/8" 100 "MySiteConfig" -AddRule -ACL $AclObject -Action Permit

    If the reader of this command is not familiar with the set-AzureAclConfig cmdlet, they may not know what the first 3 parameters are.

    The same command called using Named parameters is easier to understand:

    Set-AzureAclConfig -RemoteSubnet "10.0.0.0/8" -Order 100 -Description "MySiteConfig" -AddRule -ACL $AclObject -Action Permit

    Additional reading:

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/04/22/the-problem-with-powershell-positional-parameters.aspx

    Advanced Function names should follow standard verb-noun naming convention

    As introduced in Powershell 2.0, the ability to create functions that mimic Cmdlet behaviors is now available to scripters. Now that we as scripters have the ability to write functions that behave like Cmdlets, we should follow the consistent nature of Powershell and name our advance functions using the verb-noun nomenclature.

    Execute the Cmdlet below to get the full list of Powershell approved verbs.

    Get-Verb

    http://technet.microsoft.com/en-us/magazine/hh360993.aspx

     

    3. Issue Fixes

    • Fixed a locale issue “Input string was not in a correct format..” when Script Browser launches on locales that treat double/float as ‘##,####’. We are very grateful to MVP Niklas Akerlund for providing a workaround before we release the fix.
    • Fixed the issues (including the error 1001, and this bug report) when some users install the Script Browser.
    • Fixed the issues in Script Analyzer rules

     

    We sincerely suggest you give Script Browser a try (click here to download). If you love what you see in Script Browser, please recommend it to your friends and colleagues. If you encounter any problems or have any suggestions for us, please contact us at onescript@microsoft.com. Your precious opinions and comments are more than welcome.

  • What’s New in Script Browser & Script Analyzer 1.2

    The Script Browser and Script Analyzer apps have received nearly 15,000 downloads since they were released half a month ago.  Microsoft PowerShell MVPs provided numerous suggestions to help us improve the apps.   Based on what we have learnt in the past two weeks, today we bring to you the 1.2 update of Script Browser and Script Analyzer.  The team is committed to making the apps useful. Your feedback is very important to us.

    Download Script Browser & Script Analyzer 1.2
    (If you have already installed an earlier version of Script Browser & Script Analyzer, you will get an update notification when you launch Windows PowerShell ISE.)

     

    1. A standalone desktop version of Script Browser

    image 

    In this release, we provide a new standalone desktop version of Script Brower so that non-PowerShell scripters, e.g. SQL/VBS scripters, can also benefit from the browser.

    You can easily configure the Script Browser desktop app and the Script Browser PowerShell ISE plugin to share the favorite samples and downloaded samples.

     

    2. New Cmdlets to manually load Script Browser / Script Analyzer when you need them

    In the past releases, the Script Browser and Script Analyzer plugins are turned on automatically when you start Windows PowerShell ISE.  In this release, you can choose to manually load Script Browser and Script Analyzer into ISE when you need them.  Here is how to do it.

    First, you need to uncheck the following ‘Allow the installer to update Windows PowerShell ISE profile’ option when you install the 1.2 update.  In this way, the Script Browser and Script Analyzer will not be loaded automatically when you start ISE.

    image

    Next, when you need Script Browser / Script Analyzer in the ISE, you can type the following cmdlets to load them:

    • Enable-ScriptBrowser
    • Enable-ScriptAnalyzer

    When you do not need them, you can type these cmdlets:

    • Disable-ScriptBrowser
    • Disable-ScriptAnalyzer

    We even provided a cmdlet for starting the desktop version of Script Browser:

    • Start-ScriptBrowserDesktop

     

    3. Largely improved Script Analyzer rules

    In this release, we figured out a new solution to largely improve the speedof Script Analyzer. 

    We have also fixed all Script Analyzer issues that users have reported.  Please continue sharing your feedback with us.

     

    4. Bug Fixes

    a) Improve the startup speed of Script Browser and Script Analyzer

    b) Fixed a sample rating display issue

     

    We sincerely suggest you give the new Script Browser & Script Analyzer a try (click here to download). If you love what you see in Script Browser & Script Analyzer, please recommend it to your friends and colleagues. If you encounter any problems or have any suggestions for us, please contact us at onescript@microsoft.com. Your precious opinions and comments are more than welcome.

  • Install Script Browser & Script Analyzer from PowerShellGet of WMF 5.0

    The PowerShell team has recently announced PowerShellGet, a new way to discover, install and update PowerShell modules, in the Windows Management Framework 5.0 Preview.   In this blog, you will learn how to install Script Browser & Script Analyzer through the PowerShellGet.

    First, you need to download and install Windows Management Framework 5.0 Preview.

    Next, launch Windows PowerShell ISE, and type the following command into the PowerShell console.  The installation does not require administrator permission because it installs the apps to your current user profile.

    Install-Module ScriptBrowser –Scope CurrentUser

    image

    After the installation, you can enable Script Browser / Script Analyzer in the PowerShell ISE by entering the following cmdlets:

    • Enable-ScriptBrowser
    • Enable-ScriptAnalyzer

    image