When you’re writing a script that depends on PowerShell Remoting, it’s often helpful to know that the remoting channel is open and will support the activities of your script. PowerShell has a Test-WSMan command, but that only verifies that a WSMan connection is possible. There are other scenarios you could be impacted by: Not having permission on the remote machine Misconfiguration of the PowerShell endpoint Corrupted installation (etc) As you dig deeper, you realize that the only way to really test the viability of the remoting channel is to just do something on it, and verify that you got the results you expected to.
Over the past few years, Pumpkin carving in my family has somehow ended up focusing on two themes: Math, and Knitting. A Sierpinski Triangle – which surprisingly only took a toothpick or two to repair isolated triangles: Sierpinski Carpet (along with a wee bit of evil, of course:) Not being one to cut 64 of the level-three squares by hand, a cordless drill came in extremely handy. Mandelbrot, and Koch snowflake:
One thing you might notice if you have an iPhone connecting to an Inbox via the IMAP protocol is that messages you delete tend to stick around when viewed from other devices (such as Outlook, Outlook Web Access, etc.) This is caused by an out-of-date view of mail management, where your Inbox handles everything. When you delete an item, some IMAP clients (such as the iPhone) mark them as deleted, but don’t actually remove the item from the server.
[Edit: This function has been improved and added to the PowerShell Cookbook module. Get it from the PowerShell Gallery.] Awhile back, I introduced a script that allows you interact with remote TCP ports (such as Telnet.) While useful, it worked only interactively. It would be even more useful if you were able to script a network or TCP connection. Let me introduce Send-TcpRequest.ps1 v2, which allows exactly that: First, a simple scripted HTTP session:
When playing with cryptography challenges (don’t we all?,) you end up leaning on a bunch of common tasks. For example, substituting all text in a string with a set of replacements (substitution ciphers,) XORing strings together, applying dictionary-based algorithms, investigating word frequency, and more. PowerShell lends itself really well to these challenges, and I’ve developed a small cryptography library along the way. Here it is. Your job, as a cryptographer, is to uncover the hidden comments :) (Hint: don’t spend very long.
Adam Barr blogged bits and pieces of a PowerShell RPN calculator a few years ago: first the basics, and then some tweaks to clean it up. An RPN calculator, if you haven’t played with one before, flips the way you enter data. Rather than type “2 + 2”, you type “2 2 +”. RPN-style calculation supposedly has lots of great benefits. While I understand it and can do it, I wouldn’t say I “get it.
Last week, I dropped by to be interviewed on the PowerScripting Podcast. We chatted about providers, eventing, transactions, security, and a whole slew of V2 improvements that you probably didn’t know about! Give it a listen: http://powerscripting.wordpress.com/2009/09/27/episode-85-lee-holmes-talks-about-v2/
Call me as shocked as anybody, but the iPhone app store now has a new entry: Although I can’t find any official information about it on the rest of the internet, O’Reilly has teamed up with Lexcycle (authors of the Stanza iPhone book reading application) to create iPhone applications for many of the top O’Reilly cookbooks. Just when you thought the “PowerShell Pocket Reference” was a good value per pound, this one comes in at a net weight of zero!
Sometimes, people ask, “What’s the equivalent of NET HELPMSG” in PowerShell? NET HELPMSG is probably the easiest to remember (and works in PowerShell of course,) but PowerShell improves the experience a bunch by way of the .NET Framework. Suppose you get error 0x80070652 from an installer: C:\Users\leeholm>net helpmsg 0x80070652 The syntax of this command is: NET HELPMSG message# Oops, it doesn’t support hex. You need to take the last 4 digits:
I wanted to download a photo album from Facebook, but of course there’s no simple API or option to do that. Searching the internet finds a couple of options (a Firefox plugin, a Facebook app,) but I couldn’t seem to find anything standalone. This gives another great opportunity to talk about advanced HTTP scripting in PowerShell. We’ve talked about it in the past (here: http://www.leeholmes.com/blog/AdvancedHTTPASPNetScriptingWithPowerShell.aspx,) so this script introduces some new techniques.