PowerShell

PowerShell

January 7th, 2013 / Tech Tock

Enhance your productivity and enable rapid application development

My colleague at Lab49, Doug Finke, PowerShell MVP, wrote an excellent PowerShell book. The book seemed perfect right away:

Windows Powershell for Devlopers

The “For Developers” part really drew me in.

One of the best tricks in the book is embedding PowerShell in the GUI.  Its not hard to do.  This can be an easy win for power users of your WPF application.  Bailey Ling, another Lab49er, added Powershell to Snoop after reading Doug’s book.  He blogs about it here.

I personally now use PowerShell to coordinate my personal builds, restart my webserver and do WIP checkins to git all at once with just an F5.

Leveraging Templates in psake

July 24th, 2012 / North Horizon » Lab49

For the past few months I’ve been a technical editor for a book my good friend and colleague, Doug Finke, is writing entitled PowerShell for Developers which has just recently become available on Amazon. The purpose of the book is to show how easy it is to accomplish normally mundane, repetitive, or clunky tasks with PowerShell, a simple, concise scripting language that you already have installed on your box.

On my current project, I was recently tasked with setting up the build for our project. Of course, build scripts aren’t exactly glorious or interesting in any way and the prospect of dealing with MSBuild’s XML files gives me a fleeting sense of vertigo.

Why I Use Powershell

August 6th, 2011 / North Horizon » Lab49

I’ve been using Powershell for just over a year now, and its effect on my development workflow has been steadily increasing. Looking back, I have no doubt that it is the most important tool in my belt – to be perfectly honest, I’d rather have Powershell than Visual Studio now. Of course, that’s not to say Visual Studio isn’t useful – it is – but rather more that Poweshell fills an important role in the development process that isn’t even approached by other tools on the platform. Visual Studio may be the best IDE on the market, but at the end of the day, there are other tools that can replace it, albeit imperfectly.

Extending PowerShell to the GUI with ShowUI

July 24th, 2011 / Development in a Blink

Sean Kearny wrote Extending PowerShell to the GUI with Sapien Tools up on Hey, Scripting Guy! Blog. SAPIEN has a product, PrimalForms, which lets you create WinForm applications using PowerShell. One of the advantages using this approach; WinForms is ready out of the box on an end users Windows machine.

In this post I’ll use ShowUI and port Sean’s example. The challenge, ShowUI is a PowerShell Module that needs to be xCopy deployed to the users machine so I can create these WPF GUI applications.

PowerShell ‘Net User’ ShowUI GUI

July 18th, 2011 / Development in a Blink

Denniver Reining posted GUI Creation with PowerShell: The Basics using PowerShell and WinForms to create an application where you type a user id, click go and it executes a Net User under the covers.

Highlights

I ported his code to ShowUI and focused on the elements he did:

  • Control resizing (Using the Grid)
  • Adding controls to a Window
  • Attaching events (On_Click parameter for the button)
  • Changing control fonts (FontFamily parameter for the text box)

Using WinForms and PowerShell are a great approach to building GUIs. One advantage WinForms has over ShowUI is it is available on any machine you deliver your PowerShell script to.

The Value Per Line of Code is Amazing

July 17th, 2011 / Development in a Blink

Learn how

Wednesday July 20th I’ll be joining fellow ShowUI authors James Brundage and Joel “Jaykul” Bennett on the PowerScripting Podcast.

ShowUI is a PowerShell module to help build WPF user interfaces in script. ShowUI makes the complicated world of WPF easy to use in PowerShell. You can use ShowUI to write simple WPF gadgets, quick front ends for your scripts, components, and full applications.

Related

 

Launch a Node.js Web Server from PowerShell in Windows

July 15th, 2011 / Development in a Blink

Node.js V0.5.1 released a Windows binary. Download the Windows Build.

PowerShell

Here is an example of a web server written in Node which responds with "Hello World" for every request.

This is a single PowerShell script that saves the JavaScript to a file, launches node and then uses the .NET framework Net.WebClient to make a request.

$ip = "127.0.0.1"
$port = 337
$url = "http://{0}:{1}/" -f $ip, $port            

@"
var http = require('http');
http.createServer(function (req, res) {
	res.writeHead(200, {'Content-Type': 'text/plain'});
	res.end('Hello World\n');
}).listen($port, "$ip");

console.log('Server running at ${url}');
"@ | Set-Content -Encoding ascii c:\example.js            

Start-Process powershell -ArgumentList "C:\node\node.exe c:\example.js"            

sleep 1
(New-Object net.webclient).DownloadString($url)

Result

image

PowerShell Out-GridView–A cmdlet with benefits

July 15th, 2011 / Development in a Blink

A question I often get about PowerShell from ex-UNIX developers is whether or not PowerShell can “tail” files. Unfortunately, there is no direct analogy to the tail command in PowerShell. It’s typically used to watch the contents of a log file live as it is added to, and that is certainly something that PowerShell can do.

This question comes from a developer who is using NLog to log messages from his app involving Reactive Framework code.

Better PowerShell Splatting

July 14th, 2011 / Pelebyte » technology

One of PowerShell’s more useful and differentiating features is its ability to splat command-line arguments. Normally, to invoke a command in PowerShell with arguments, you could do something like this:

Get-Process -Name *Tomcat* -ComputerName somebox.around.here

It may be useful to capture the arguments first, then invoke the command later:

$myArgs = @{ Name = "*Tomcat*"; ComputerName = "somebox.around.here" }
Get-Process @myArgs

It can also be incredibly useful if you’re writing wrapper functions:

Updated, Hippy Dippy PowerShell Clock with ShowUI

July 13th, 2011 / Development in a Blink

image

I posted PowerShell Clock with ShowUI. Ravi, another PowerShell MVP, tried the sample using the AsJob parameter. The AsJob will run the PowerShell WPF GUI in the background. Unfortunately, the FontSize and other parameters would not set correctly and the clocked was not readable.

After emailing James Brundage, a fellow ShowUI author , he blogged Six Steps for Writing ShowUI Controls and a video tutorial based on this clock example.

Definitely check it out, he kicks it up a notch with data context’s, PowerShell DataSources. splatting, adding event handlers and more.

PowerShell, ShowUI and the Twitter API–Part 2

July 9th, 2011 / Development in a Blink

Part 2 builds on the first 30 lines from PowerShell, ShowUI and the Twitter API–Part 1 (Check out the video tutorial for building it) and positions the script for the next set of steps.

More updates coming soon.

image

Updates

This version lets you view multiple Twitter search feeds. Type in a search and press enter and another column is displayed. You can delete a column too.

PowerShell Code

Download it HERE from my repository. Download ShowUI.

PowerShell Clock with ShowUI

July 7th, 2011 / Development in a Blink

Richard Siddaway posted A PowerShell Clock using WPF and demonstrated some nice features.

  • A windowless window
  • Ticking digital clock
  • Moving the window by clicking and dragging even though it doesn’t have a border

image

The ShowUI Code

Here is the ShowUI code. Note the On_* keys in the hash table. They handle the mouse button events and the windows load event where I register a PowerShell script block that executes every half a second. This updates the time and enables the ticking digital clock.

Secrets to Building a WPF Application in Windows PowerShell

July 5th, 2011 / Development in a Blink

Check out my MSDN Article on PowerShell and WPF:

Secrets to Building a WPF Application in Windows PowerShell

Special bonus

Windows PowerShell creator Jeffrey Snover weighs in on the Ad Hoc development model and origin of the language.

Related Topics

Share

My MSDN Magazine article is out–PowerShell & WPF

July 1st, 2011 / Development in a Blink

Secrets to Building a WPF Application in Windows PowerShell

Thank You

I want to thank Jeffrey Snover, Distinguished Engineer, Lead Architect for Windows Server and father of PowerShell. He eagerly and graciously agreed to write the sidebar for the article and offered great feedback.

Also, thank you to James Brundage, founder and lead developer of Start-Automating, creator of the PowerShell Pack and WPK. He provided excellent insight on my drafts. Hat tip to Joel Bennet, author of PowerBoots.

Finally, thank you to my colleagues who took the time to read and offer suggestions.

PowerShell, ShowUI and the Twitter API

June 26th, 2011 / Development in a Blink

Checkout the video tutorial and the less than 30 lines of code.

The Result

I built this WPF application using PowerShell and ShowUI. I used a single Url to get the data back from the Twitter API, sliced and diced the XML in PowerShell, used WPF Databinding, Templates, a Grid and ListBox (and a little more) to get this visual.

image

The Video

 

I Presented PowerShell for .NET Developers

June 18th, 2011 / Development in a Blink

At the Hartford Code Camp. It was a full room and while fewer developers have used PowerShell, when I asked what brought them to my talk, the response was they are hearing PowerShell will be fundamental when interacting with Windows going forward.

My demo covers

  • Cmdlets
  • Piping
  • Working with XML
  • Compiling C# on the fly in a script
    • Using the object just created in the same PowerShell
  • Configuring the Debug tab in VS 2010 for launching ISE (Integrated Script Environment)
    • Setting a break point in that C# file, run a script and step through both the C# and PowerShell

PowerShell ShowUI Video Tutorial–Hello World

June 14th, 2011 / Development in a Blink

I put together this short tutorial using ShowUI (download ShowUI HERE). ShowUI is a PowerShell module to help build WPF user interfaces in script. You can use ShowUI to write simple WPF gadgets, quick front ends for your scripts, components, and full applications.

Basic Building Blocks

In the video I demo the basic building blocks you’ll reuse over and over. New-Window, New-StackPanel, New-Label, New-Button and more.

Take a look and let me know what questions you’d liked answered. I’ll include them in the next set of video tutorials.

Share

Cisco announces a PowerShell Tool kit for their Unified Computing System

June 10th, 2011 / Development in a Blink

As these type of offerings increase, it will become more and more important for developers to PowerShell enable the applications they deliver. This will greatly improve their cycle time by streamlining their software delivery process.

The Cisco Unified Computing System is the  next-generation data center platform accelerates the delivery of new services simply, reliably, and securely through end-to-end provisioning and migration support.

UCS PowerShell Toolkit (PowerTool) and .NET SDK for UCSM

UCS PowerShell PowerTool helps customers integrate, automate, and orchestrate all aspects of UCS management including network, storage and hypervisor management with their existing IT management processes.   Microsoft PowerShell is fast becoming a defacto standard for automating and integrating many functions of systems management within the datacenter.

WPK + PowerBoots => PowerShell ShowUI

June 6th, 2011 / Development in a Blink

Version 1.0 is up on CodePlex HERE.

ShowUI is a PowerShell module to help build WPF user interfaces in script. ShowUI makes the complicated world of WPF easy to use in PowerShell. You can use ShowUI to write simple WPF gadgets, quick front ends for your scripts, components, and full applications.

History

Back in 2008 I blogged about Ruby Shoes and the start of a PowerShell version. Shoes is a GUI framework for Ruby. I figured why not a WinForms GUI framework for PowerShell.

Here is the Ruby Shoes example in ShowUI today:

image

One clear advantage of OData is its commonality

June 2nd, 2011 / Development in a Blink

If you care at all about how data is accessed–and you should–understanding the basics of OData is probably worth your time.

Dave Chappell’s post, Introducing OData, does a great job walking through what OData is. Covering REST, Atom/AtomPub, JSON, OData filter query syntax, mobile devices, the Cloud and more.

Our world is awash in data. Vast amounts exist today, and more is created every year. Yet data has value only if it can be used, and it can be used only if it can be accessed by applications and the people who use them.
Allowing this kind of broad access to data is the goal of the Open Data Protocol, commonly called just OData. This paper provides an introduction to OData, describing what it is and how it can be applied.