PowerShell in the Azure Portal… Almost!

  A little while back I noticed a new (but familiar) icon in the Azure portal (see below, not above)…   I was gutted to see the following for PowerShell… coming soon!   Good things come to those who wait, but if you can’t wait you can sign up to a Private Preview by following…

0

Intelllisense in the Console

You’re running a cmdlet in the PowerShell.exe host console. You want to see what parameters are available to you. You can tab through them, after inputting a hyphen, until you get the one you want… but, how do you display them all and then chose the one you want, avoiding the help file?    Enter …

1

Scripting Tips & Tricks: Dynamic Parameters

Imagine you want a secondary parameter (or set of parameters) to ONLY appear if a particular value has been supplied to an initial parameter… Eh? Ok, so you have Parameter A. You supply Value A to Parameter A and you now, and only now, have access to Parameter B. Furthermore, if you were to supply…

0

AD Cmdlet -Filter Faffing

I’m aware that I write for an international audience and I try to use international English in my posts.   When I use traditional or colloquial English I usually have a good reason for doing so. Today’s reason is because I like the alliteration that ‘Filter Faffing’ provides.   faffing – the act of making…

6

Scripting Tips & Tricks: Dynamic RegEx Queries

Another week of RegEx! I just can’t get enough of it at the moment. A bit like sleep. I said sleep, not sheep! Man, I do like a good sleep. I’m writing this at an airport. It’s way past my bedtime. Anyway… what do I have for you this week? Well, I feel like a…

0

Scripting Tips & Tricks: RegEx for OU Name & Path

I ‘borrowed’ this RegEx off my esteemed colleague, Mr Raimund Andree, whilst working on site with him.   $pattern = ‘(..=)(?<Name>.*?)(?<!\\),(?<Path>.*)’   You can use this pattern to match the ‘Name’ of the OU and its parent ‘Path’ into named groups with those exact same names.   $a = “OU=TEST,DC=Halo,DC=net”,”OU=BATCH1,OU=TEST,DC=Halo,DC=net”,”OU=BATCH2,OU=TEST,DC=Halo,DC=net”,”OU=BATCH3,OU=TEST,DC=Halo,DC=net” foreach ($b in $a) {…

0

Scripting Tips & Tricks: Review Your Comments

I wrote a PowerShell module recently as part of an update to a service we provide to customers. I needed to dump out all of the comments so they could be submitted for review. I wanted to ignore comment based help sections.   Here’s how I did it with the aid of RegEx…   $a…

0

Security Focus: Generate an Alphanumeric Password

If you have to have a password, it’s best to have a password that could contain special characters… but, what if you want to generate a password without special characters? Here’s a little function to do just that:   function New-AlphaNumericPassword { ##14 characters ##no special characters ##ASCII #48 -> 57 :: 0 -> 9…

0

Add Multi-Line Content to a Linux File with Add-Content

You have a large number of files to edit that are used by Linux servers. The editing and distributing of these files has to be done on a Windows platform. You want to append some multi-line detail to these files with PowerShell, but the file still needs to be compatible with Linux. Now, Add-Content with a here string would seem to…

2

One-Liner: PowerShell Pi Mnemonic

I love this. I came across it when looking into how to calculate Pi with PowerShell.   “$(‘How I wish I could calculate Pi better’.split(‘ ‘) | % {$_.length})”     I’ve tweaked it ever so slightly.   $(‘How I wish I could calculate Pi better’ -Split ” ” | % {[string]$a += $_.length}; $a.Insert(1,”.”))…

1