One-Liner(s): X509 Certificate Store Names and You

All right, we know that we can access a remote computer’s various X509Certificate stores via .NET, and ‘My’ corresponds to “Local Computer\Personal\Certificates”. What are the other names? http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.storename.aspx That gives us the details, but on some of my lab boxes, some of it didn’t work. Specifically, I couldn’t pull the Intermediate Certification Authorities list. Per…

1

One-Liner: Case-Insensitive XML Queries

I’m a one-trick pony with XML.  I use $xml.SelectNodes(“//name[@attribute=’value’]”) and permutations thereof.  However, XML’s SelectNodes() and SelectSingleNode() methods are case-sensitive.  My coworker Keith Munson found this tidbit:  $xml.SelectNodes(“//element[translate(@AttributeName, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘abcdefghijklmnopqrstuvwxyz’) =’AttributeValue’]”) This will return <element AttributeName=”attributevalue” /> as well as <element AttributeName=”AttributeValue” /> But it won’t work for <Element AttributeName=”AttributeValue” /> nor: <element attributename=”AttributeValue” />…

0

Regular Expressions, Search-and-Replace Interpolation and Delegates

This (and the previous post) stem from me stumbling onto this page: http://stackoverflow.com/questions/17229866/powershell-hex-to-string-conversion/19151495 Last time, we looked at hex-decoding a string. In the above, the original poster had file of space-delimited lines, each with three fields: the username, the user’s domain, and the hex-encoded password. The requested solution was to only hex-decode only the third…

0

Splitting a Hex-Encoded String into Pairs of Hex Characters (a.k.a. To Pull a Noah)

Simple enough task: I have a hex-encoded string and need to decode it.  Now, we all know that to encode a string to hex is to cast each [char] to [int], then shove it through the "{0:X}" format specifier, then concatenate all the strings. $string = "The quick brown dog"; [string]::Join($null, ([char[]]$string | % {…

1

Tip: Passing [switch]Parameters to Nested Functions

Here’s something that bedeviled me for the longest time: if I have a [switch] type parameter at the script level, how do I pass it to the core function it calls? # script Test-It.ps1 will call Test-It function param (      [String[]]$ComputerName = @(),      [switch]$Full     ); function Test-It {      param (          [String[]]$ComputerName = $script:ComputerName          [switch]$Full      );          …

1

Rehash: Playing with Window Size

http://blogs.msdn.com/b/timid/archive/2011/06/23/playing-with-window-size.aspx gave the core magic for messing with the console window size.  Since then, I’ve seen functions that allow the user to set it to arbitrary values, but I found myself wanting to grow and shrink the window size by some specified delta, e.g. +10 columns, when generating the ‘test pattern’ from yesterdays’ post.  Why…

0

Capturing the Console Buffer

Vladimir Averkin’s http://blogs.msdn.com/b/powershell/archive/2009/01/11/colorized-capture-of-console-screen-in-html-and-rtf.aspx provides the code.  Here’s the core magic. $Host.UI.RawUI.GetBufferContents(System.Management.Automation.Host.Rectangle) will return a two-dimensional character array of the contents of the buffer. This entry cleans up the HTML function by creating XML instead of using System.Text.StringBuilder to append strings.  Sadly, I don’t know RTF at all, so this is merely a merging of that…

0

Lenovo W530 and the Context Menu Key

The context menu key looks like this: It’s normally on the same row as the space bar, usually to the right of it: This is how a Lenovo W530 (and Carbon X1, and probably many other current-generation models) keyboard looks: Notice anything missing? Now, I could hit Shift+F10 any time I need the context menu…

11

Windows 8, the F8 Key, and You

Welcome to Windows 8.  Quick, how do you revert back to the last system restore point?  To refresh your memory, here’s how you create a restore point: Right click on My Computer, then select Properties.  From the menu on the left, select System Protection: In the resulting dialog box, click Create: Name it something useful,…

0

Printing to Text

Yes, you can still print to a file in Windows 8.  Very handy. Start | Control Panel | Devices | Printers | Add Printer Click on ‘The printer that I want isn’t listed’ Click on ‘Add a local printer or network printer with manual settings’ Use an existing port: FILE (Print to File) Manufacturer: Generic,…

0