Cross Domain Remoting

I’ve seen a couple questions about cross-domain PowerShell Remoting online this week. I do this often and actually just recently finally started building some tooling around making it easier to work with on a daily basis. http://www.reddit.com/r/PowerShell/comments/37nw55/crossdomain_remoting/ @LogicalDiagram @jsnover @almostjulian @abhik501 Can you point me to solid directions, and what WMF versions are required? — Rob Nelson (@rnelson0) May 28, 2015 I referenced this Scripting Guys article which has some good information on remoting to an untrusted domain.

Blog Refresh

AKA: When a new blog post turns into yak shaving. I’ve seen some questions online about PowerShell Remoting across different domains. It’s not a topic that’s well covered but there is some content available. I wanted to put up a quick post to help people find that content. Well, I’ve replaced my laptop since my last blog post and this one isn’t set up with the Ruby libraries necessary to work with Octopress.

Simple PowerShell File Picker v2

I made a couple of changes to the function to support recursively stepping into directories. I started messing around with this snippet in order to reproduce the functionality of using the Windows OpenFile dialog with a one-liner. Now it’s a bit more than a one-liner, but the GridView UI is actually pretty useful if you don’t know exactly what file you’re looking for.

Simple PowerShell File Picker

Here is a simple function to create a basic graphical file picker.

Inspired by the more robust, but more verbose snippet posted on powershell.com.

Tools: PowerShell Providers & Website Creation

I found two great tools yesterday. Actually, that’s an grossly inaccurate statement. One of the tools I learned about at the PowerShell Summit earlier this year, but was just finally published to GitHub. The second tool isn’t really a tool, but a site indexing a bunch of tools, or frameworks, for generating static websites.

Wasted Time

I have been sitting here staring at my computer for over two hours now. Essentially locked out of my system for a full disk virus scanned enforced by The Man (aka Corporate IT). The scan thrashes my slow laptop harddrive so much that opening even a simple web page requires a Buddhist monk’s level of patience. The job has a runtime limit of two and a half hours.

New Relic is a Bit Sweeter

I’ve been working with New Relic a lot in recent weeks and have deployed their agent several times. Obviously, this required some automation and the best way to automate software installs on Windows is Chocolatey. Unfortunately, New Relic didn’t publish their agents to Chocolatey and the existing packages were out of date.

I brought up the request on the user forum and New Relic expressed interested, but also said, “feel free to give it a try yourself.” So, I did.

Messing with Photos in PowerShell

In continuing with the habit of building wrappers around .Net libraries mentioned on Scott Hanselman’s blog, I have written a module around James M South’s ImageProcessor.

Here’s an example.

Get-PIPImage -Path C:\Pictures\DSC06199.JPG | 
    Set-PIPImageSize -Width 500 -Height 500 -MaintainAspect | 
    Add-PIPFilter -Filter lomograph | 
    Add-PIPRoundedCorners | 
    Set-PIPImageFormat -Format Png | 
    Save-PIPImage -Path c:\temp\whisky.png

And here is the result.

Whisky

Humanize follow-up

Humanizer helps you generate some nice output, but it’s kind of a pain to use in PowerShell. You can use Update-TypeData to make the syntax easier to work with. Then, your code starts to look more like the examples on the project’s site.

Here’s a simple example.

Add-Type -Path C:\Humanizer\Humanizer.dll

Update-TypeData -TypeName System.Int32 `
    -MemberType ScriptProperty `
    -MemberName ToWords `
    -value {[Humanizer.NumberToWordsExtension]::ToWords($this)}

PS C:\temp> $int = 1234
PS C:\temp> $int.ToWords
one thousand two hundred and thirty-four

Humanize your scripts

This is a quick example of some of the stuff you can do with Humanizer to make your script’s output a bit more user friendly.

Strings from numbers.

PS C:\temp> [Humanizer.NumberToWordsExtension]::ToWords(2)
two

PS C:\temp> [Humanizer.NumberToWordsExtension]::ToWords(253)
two hundred and fifty-three

PS C:\temp> [Humanizer.ToQuantityExtensions]::ToQuantity("box", 4)
4 boxes

Book Review: Thinking, Fast and Slow

I finished this book a few weeks ago and have struggled with how to write a review. Thinking, Fast and Slow by Daniel Kahneman is the most epic self-help book I have ever read. It’s also different in the fact that there is no “do this or that to live a better life” type advise, but simply over 400 pages of examples of hour your brain can fail you in so many situations.

Test All The Things

This is a follow-up to my last post on using PSate for test automation. I demonstrated running Invoke-WebRequest and validating the StatusCode as a simple test for if a site is available. Now let’s take it to the next level and run an artificial transaction. Again, PSate is a handy test runner to manage this and the open-source project, WatiN (pronounced as What-in) is a great tool for automating a real browser.

Test it with Psate

Recently I have been putting effort into learning the art and science of unit testing using Pester and PSate. I was going to write up something on my experiences, but Jakub JareŇ° beat me to it with this”) good article on PowerShell Magazine. If you are new to the idea of unit testing, go read that article and then come back here.

So, what is the point of this article? I was working on an unusual maintenance recently and it was around 4 in the morning and it occurred to me that it would be nice if I had a big dashboard that showed everything was “green”.

One Year

American Visitors I happened to look through all of the previous posts today and found that 2/25/2013 was my first. So, that makes a year and by no conscious effort, 52 posts—one a week on average. The site receives about 500 visits a month from over 40 countries.

Book Review: The Checklist Manifesto

I thought I would try something new for this post, a book review.

I recently read The Checklist Manifesto: How to Get Things Right and it was one of the best non-fiction books I have ever read. That’s the short of it. Go read the book.

If you are still not convinced, here is a bit more about the book and why I feel it’s a top read for anyone who thinks this blog is even slightly interesting.

Angular Posh

I just recently found out about a fun project, PoSH Server that has actually been around quite a while. Executing PowerShell from a web page is a powerful idea for a Windows Administrator. Simply access a URL and get back some HTML formatted data—easy to run and consume the results. Just like everything involving PowerShell, there are a number of way to tackle this and I’ve tried quite a few including: PowerShellASP (now PowerShellServer) by /n Software; and Edge for NodeJS. The beauty of PoSH Server is that it’s written entirely in PowerShell which makes it easy to run and tweak. You don’t even need IIS installed. If you have PowerShell installed, install the module and run Start-PoshServer. That is all. Well, that’s enough to get you started. Where you go from there is the challenging and fun part.

Command line tools

The good folks over a Royal Pingdom posted an article today entitled “Powerful command line tools for network administrators.” Of course, by network administrator, they mean Linux admin. Here’s my version for you Windows admins. I guess you could call it “PowerShell command line tools for network administrators.”

Tools: NSSM

The Non-Sucking Service Manager

NSSM is a really simple application for creating a Windows service from any executable command.

It’s similar to srvany if you’ve ever used that before. NSSM includes support for handling application exits depending on the exit code. That’s about it. There’s not much to it, but it is quick and simple way to solve a not-uncommon problem&madsh;make something run without requiring me to log in and start it.

Get-StoredCredentials Module

Password Vault'

If you’re doing security right, the credential you use to log into your workstation is not the same used to managed the Production environment. Because of that practice, I have to run Get-Credential almost every time I open up a new Powershell session and type in details manually. There are plenty of options for storing credentials securely and one has been standard in Windows for over a decade—Windows Credential Manager. Why has no one built a script for getting and setting credentials from this store?

Powershell Desired State Configuration

Lights Cross Processed by Tarnished_Plastic, on Flickr

Yesterday, Microsoft revealed a new feature of Powershell v4 that is included in Server 2012 R2—Powershell Desired State Configuration. At first glance this looks to compete directly with Chef and Puppet, but during the presentation, OpsCode actually stepped in to present how they’ve already adopted the new technology into Chef. If you already use Chef and are familiar with the Ruby based DSL, you can continue to use it. System Center 2012 R2 is also built on top of this framework. It is the new way of thinking for Windows system configuration automation.

Here is an example configuration script. It only scratches the surface of the capabilities demoed by Kenneth Hansen and Jeffrey Snover at TechEd.

Windows Audio Device Cmdlet

Basic command-line audio device control from Powershell including Nuget Package Manager Console. On GitHub Features: Set Volume and toggle Mute on the Default Playback Device. Get a list of devices and set the Default Audio Device. Install. Download New-Item “$profile\Modules\AudioDeviceCmdlets” -Type directory -Force Copy CoreAudioApi.dll, AudioDeviceCmdlets.dll and AudioDeviceCmdlets.dll-Help.xml Import the binary module. This can go into your profile. Import-Module AudioDeviceCmdlets You may need to set the execution policy. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned Suggested Aliases.

Software Deployments with psake on Windows

I’m working on the finishing touches of a Deployment Automation script useing psake (pronounced like sake—the Japanese rice wine) as the framework for creating discreet jobs and enforcing dependencies.

This Site: Follow-Up

Following up to the original post.

I’ve been running this site for over a month now and have a full AWS billing cycle report I can share.

Tools: Pipeworks

PowerShell Pipeworks is a pretty interesting module for PowerShell. Most modules for Posh are focused on doing some discrete task(s). The design principle of Cmdlets is to make single function executables just like Unix shell commands.

I think Pipeworks is the first 3rd party framework I’ve seen developed on Powershell. It’s scripting glue you can use to build automation with Service Oriented Architecture principles. With PowerShell v3 and the whole Windows Management Framework it was packaged in, there is a new Powershell feature called Workflows. Workflows was designed and released also to solve the problem of orchestrating more complex sequences of logic.

Nginx As a Forward Proxy

Everyone wants to do SaaS these days and that includes Infrastructure Monitoring software. That’s a problem when half of your servers do not have internet connectivity and you’d like it to stay that way.

What this site runs on

I’ve wanted to share some of my my experiences working in a Microsoft based SaaS environment and thought about blogging before, but I’m not really a writer. I finally started this site as an experiment to try technologies that I don’t normally get to try in my day to day professional experience.