Archive for the 'PowerGUI Pro MobileShell' Category

Video: Sean Kearney – The Most Energized PowerShell MVP

At the MVP Summit this year I could not help recording this quick chat with the one and only ye110wbeard, a.k.a The Energized Tech, a.k.a. PowerShell MVP from Canada – Sean Kearney:

We talk about PowerShell (surprise! :)) and what he likes the most about it:

  • Simplicity to get a lot of things in one command,
  • Ease of Active Directory management (Unlock-QADUser is his favorite cmdlet),
  • Ability to connect to web services from PowerShell scripts,
  • PowerShell on his BlackBerry smartphone (via PowerGUI MobileShell), and
  • Ways to get started with PowerShell.

For even more Sean’s videos visit his own video channel here.

Most other PowerShell MVPs make guest appearances in the background. As a bonus entertainment feature: see how many of them you can count! 😉

Advertisements

PowerGUI Pro Technical Brief

Darin posted a quick document describing the major features of the PowerGUI Pro version (which are MobileShell, script version control, and technical support) here.

He provides pretty detailed information on what each of them actually means so it should help you figure out whether you want to download the trial of the Pro version (which I obviously highly recommend) or stick to the free version (by the way, they can run side-by-side).

Download the PowerGUI Pro Technical Brief here (registration required.)

PowerGUI Pro with MobileShell Released

The final code and trial keys are now freely available at www.quest.com/PowerGUIPro.

As I mentioned previously, this is essentially the same as free PowerGUI 2.0 available from PowerGUI.org but has version control for PowerShell scripts and MobileShell (PowerShell in a browser including full support for Linux, Mac, iPhone, etc.)

Thanks to everyone who helped beta-test this great release. Give it a try – go to the PowerGUI Pro page, download the final code, get a free trial license, and hopefully buy the product.

My First MobileShell Client

In-browser PowerShell command-line is not the only way to take advantage of the PowerShell-running web server.

With the help of the PowerGUI MobileShell SDK, you can build your own MobileShell clients and use all the same web services MobileShell is using for a totally different user experience. For example, you could build your own native iPhone, Android, Blackberry, or Windows Mobile clients, Silverlight PowerShell applications and so on.

Here’s a quick step-by-step tutorial to get started with the SDK. For simplicity sake I will be using Visual Studio 2010 (Release Candidate) and build a console application. It should be quite easy for you to do the same in your favorite development environment of choice. 🙂

So let’s get started. Open Visual Studio, and create a New Project / Console Application (Visual C#) – I will call mine MyMobileShellConsole:

Then, on the Project menu, click Add Service Reference. For simplicity sake, click the Advanced button on that dialog box, and then click the Add Web Reference button at the bottom of the Advanced options screen.

In the Url edit box, provide the URL of the web services endpoint for your MobileShell installation: e.g. http://my-server-name/MobileShell/MobileShell/MobileShellWebService.asmx or https://my-server-name/MobileShell/MobileShell/MobileShellWebService.asmx (mind http or https). You will then be prompted for credentials of the account which has access to the server.

Also, change the Web reference name to something more meaningful – e.g. MobileShell.

Now we can open the Program.cs file (obviously, if you are not writing a console application) you will have something else.

Add a ‘using’ clause to include the MobileShell namespace:

using MyMobileShellConsole.MobileShell;

And run our ‘Hello World’ script in the main function:

// Connect to MobileShell web service endpoint
MobileShellWebService webService = new MobileShellWebService();
webService.CookieContainer = new System.Net.CookieContainer();
webService.Url = 
  "http://MyServer/MobileShell/MobileShell/MobileShellWebService.asmx";
webService.Credentials =
  new System.Net.NetworkCredential("MyAccount", "MyPassword");

 

// Execute our first script
ScriptState state = webService.ExecuteScript("'Hello World'");
System.Threading.Thread.Sleep(1000);

// Retrieve results
state = webService.GetCurrentScriptState();
Console.WriteLine((state.Command as WriteCommand).Text);

 

Console.ReadLine();

Your project will probably look like this:

That is it. You can now run the application, have your ‘Hello World’ script executed at the MobileShell server and get the results back.

As a Step 2, let’s have a slightly more advanced script, which would actually prompt user for the command, keep retrieving results while they arrive, and so on – this is quite easy to do as well:


// Connect to MobileShell web service endpoint
MobileShellWebService webService = new MobileShellWebService();
webService.CookieContainer = new System.Net.CookieContainer();
webService.Url =
  "http://myserever/MobileShell/MobileShell/MobileShellWebService.asmx";
webService.Credentials =
  new System.Net.NetworkCredential("MyUsername", "MyPassword");

// Prompt user for command
Console.WriteLine("Type PowerShell command to execute: ");
String strScript = Console.ReadLine();

// Execute it
ScriptState state = webService.ExecuteScript(strScript);

// Keep retrieving results until execution is completed
while (state.State != PipelineState.Completed)
{
    System.Threading.Thread.Sleep(100);
    state = webService.GetCurrentScriptState();
    if (state.Command != null) {
    Console.WriteLine((state.Command as WriteCommand).Text);
    }
}

webService.TerminateCurrentScript();
state = webService.GetCurrentScriptState();
Console.WriteLine((state.Command as WriteCommand).Text);

Console.ReadLine();

With this one, you can get a bit more fancy:

And there’s more! You can use web services to retrieve intellisense information, manipulate favorites, format output, and so on. See more examples here and build your own MobileShell clients and any PowerShell applications which you need running on PowerShell-less devices!


My Recent Tweets

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

September 2019
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
30  
Advertisements

%d bloggers like this: