Scripting Tips & Tricks: ISE – Alt + Shift + Left Mouse Button

Here's a very useful one shown to me by one of my Dutch colleagues, Stefan Stranger. I keep using this over and over, so it's going to be of value to others.   Problem You've got a block of code in your ISE that you've tabbed / indented across too much. Eh? Look at this:  …

3

Scripting Tips & Tricks: The PowerShell Script Analyzer Module

I love this new module. It makes adhering to scripting recommended practices an absolute doddle. And there's no need to go and download it from a repository as it comes bundled with v5!   Unleash the Beast Let's have a look at the cmdlets that  come with the psscriptanalyzer module:   Now, run Invoke-ScriptAnalyzer against one of my more…

2

Scripting Tips and Tricks: Param()

Param() – the next instalment in the exciting Scripting Tips and Tricks series! I'm a tidy person: tidy desk, tidy mind, and all that jazz. I believe in being as thorough and proper in my scripts and functions as possible. To that end, I delight in using PowerShell features such as: #Requires… to ensure certain conditions…

1

Scripting Tips and Tricks: CmdletBinding()

It’s been a little while since we’ve had a Scripting Tips and Tricks post… and, boy, what a topic to return on – CmdletBinding! The last Tips and Tricks post talked about using Write-Verbose in scripts and advanced functions. It’s just one of the features enabled with CmdletBinding. Here’s a snippet of what I had to say last time out:…

3

Scripting Tips and Tricks: Write-Verbose

A couple of weeks ago I reminisced about message boxes. In that post I mentioned that I use the Write-Verbose cmdlet in scripts. Here's how why and how… Why? Information sent to the verbose message stream can aid troubleshooting. It's also great for tracking the progress of a script or function. How? With version 2 of PowerShell 'advanced functions' made…

3

Scripting Tips and Tricks: Message Boxes

I used to write a lot of VBScript scripts* and a high percentage of them employed a dialogue box or two. Whether using the WScript.Shell PopUp method or the MsgBox keyword, I delighted in writing messages to screen!     How times have changed: I can't recall ever using a message box in a PowerShell script; on occasion, I use Write-Host and I certainly make use of…

1

Scripting Tips and Tricks: Strict Mode

Dealing with the PoSh progeny, it is important to possess a Strict Mode to compliment the now famous Naughty Step*. Such techniques maintain discipline and keep the troops in line. My Strict Mode is as far removed from the Wackford Squeers' school of discipline as one can imagine, being nothing more than a raised voice, but, by Jove, it works wonders!  PowerShell also has…

1

Scripting Tips and Tricks: Requires

The PoSh family require lots of things. Food, warmth and shelter seem to be at the top of their list. Attention is up there, too. Interestingly, the PoSh chickens have similar requirements… although, PowerShell still doesn't figure on THEIR list. More interestingly, scripts have requirements: a certain script may require administrative privileges, another the Azure PowerShell module. Scripts never…

1

Scripting Tips and Tricks: Script Development with Splatting

Advice can be given, ignored or taken. Over the next few weeks I'll write about some scripting practices I find useful and helpful. You can decide if these tips are for you… When writing a longer script I often have to work on it as and when I can. These scripts tend to have lots of parameters and I…

1