• Creating a PowerShell Script Gallery Upload ISE Add-On – Part 2

    In part 1 of this blog post series I showed the end result of the PowerShell Script Gallery Upload ISE Add-On which I created. In this post I explain the steps I took to create this ISE Add-On.

    As starting point I used the blog post from Jason Stangroome called Create a PowerShell v3 ISE Add-on Tool.

    The high-level steps are the following:

    1. Open Visual Studio and create a new WPF User Control Library project. The new project should contain a new UserControl1.
    2. Add a new Project Reference to the Microsoft.PowerShell.GPowerShell (version 3.0) assembly located in the GAC.
    3. Open the UserControl1.xaml.cs code-behind file and change the UserControl1 class to implement the IAddOnToolHostObject interface.
    4. Add Browser Object to UserControl1.
    5. Add PowerShell script to load ISE Add-On as reference.
    6. Build Solution.
    7. Open ExamplePowerShellISEAddOn.ps1 from build folder in PowerShell ISE.

    Pre-requisites:

    • Visual Studio (I used Visual Studio Ultimate 2012)

    Step 1. Open Visual Studio and create a new WPF User Control Library project. The new project should contain a new UserControl1.

    image

    Step 2. Add a new Project Reference to the Microsoft.PowerShell.GPowerShell (version 3.0) assembly located in the GAC.

    image

    image

    image

    Step 3. Open the UserControl1.xaml.cs code-behind file and change the UserControl1 class to implement the IAddOnToolHostObject interface.

    Before:

    image

    After:

    image

    Save.

    Step 4. Add Browser Object to UserControl1.

    image

    Search in Toolbox for WebBrowser Control and drag and drop on UserControl1.xaml.

    Go to properties pane for new WebBrowser Control.

    image

    Enter Source.

    image

    Step 5. Add PowerShell script to load ISE Add-On as reference.

    Open PowerShell ISE and save following script with correct folder path to c:\temp\ExamplePowerShellISEAddOn.ps1

    add-type -path "C:\Users\stefstr\Documents\Visual Studio 2012\Projects\ExamplePowerShellISEAddOn\ExamplePowerShellISEAddOn\bin\Debug\ExamplePowerShellISEAddOn.dll" $psISE.CurrentPowerShellTab.VerticalAddOnTools.Add('ExampleISEAddOn', [ExamplePowerShellISEAddOn.UserControl1], $true)

    Go back to Visual Studio and add ExamplePowerShellISEAddOn.ps1 add PowerShell script as existing item.

    image

    image

    Step 6. Build Solution.

    image

    Step 7. Open ExamplePowerShellISEAddOn.ps1 from build folder in PowerShell ISE.

    image

    image

    image

    Next steps you could do is improving the WebBrowser Control or adding navigation buttons and code to the ISE Add-On.

    You can also look at Script Gallery ISE Add-On project page for what I’ve added to the WebBrower control.

     

    References:

  • New Operations Manager Dashboard section Script Center

    We recently added an area for sharing scripts for SCOM dashboards featuring PowerShell extensibility widgets to the TechNet Script Center repository. This is a centralized location with PowerShell scripts for the extensibility widgets.

    image

    image

    I’ve uploaded my PowerShell Grid Widget Helper script to this section too. And did you know I also used my PowerShell Script Gallery Upload ISE Add-On to upload my Helper function from within the PowerShell ISE?

     

    image

    Check my script here: http://gallery.technet.microsoft.com/PowerShell-Grid-Widget-226ef153

    Let’s upload your scripts for SCOM dashboards featuring PowerShell extensibility widgets to the TechNet Script Center repository!

    Final tip. You can use the Microsoft Script Browser ISE Add-On to search for those Dashboard script from within the PowerShell ISE.

    image

  • Creating a PowerShell Script Gallery Upload Add-On – Part 1

    Some weeks ago I started a discussion on Codeplex requesting an option to upload your PowerShell scripts to the TechNet Script Center being part of the Microsoft PowerShell Script Browser.

    .One of the main features in the Script Browser is to search, download, and learn script examples from the TechNet Script Center.

    image

    Until now most of the scripts I create are shared on Github.Mainly because it’s pretty simple to upload scripts to my Github repository. But the more scripts I and you upload to the Microsoft Script Center the more scripts can be found using the Script Browser.

    So instead of waiting for some responses on my discussion thread on Codeplex I tried to create a PowerShell ISE Add-On which makes it easier to upload your scripts from the PowerShell ISE to the Script Center.

    image

    The wish list for this ISE Add-On was the following:

    1. You must be able to easily upload your PowerShell script from PowerShell ISE. Easily means without leaving the ISE and not having to type to much information on the Upload page.
    2. You must be able to navigate on the Upload page from within the ISE
    3. You must be able to insert the file name into the File Upload text box with one click
    4. You must be able to insert as much as possible information available in the script to the Description field.
      As much as possible means the Script Comment Header information I always insert at the top of my PowerShell scripts.

    After reading below documentation I created a beta version of the PowerShell Script Gallery ISE AddOn on Github.

    You can test this beta version if you want.

    Steps:

    1. Download the v0.1-beta.zip file from the release folder.
    2. Unblock v0.1-beta.zip file.
    3. Extract v0.1-beta.zip to folder of choice.
    4. Run LoadScriptGalleryISEAddOn.ps1 from within the ISE.

    In the next part of this blogpost I’ll describe the steps I followed to create this PowerShell ISE Add-On.

     

    References: