Get and Set the compilation debug flag in web.config

Since the main technology I support as a PFE is IIS, I often find myself writing scripts for IIS or ASP.NET management. For example, one of the first things I check when troubleshooting ASP.NET applications is the debug flag in the web.config. For this, I’ve written the following two example functions that use the accelerator…


PowerShell scripting best practices

For the past few years, I’ve picked up a several best practices for PowerShell scripting. Some of them are “borrowed” from Ed Wilson (aka the Microsoft Scripting Guy), Don Jones, and other PowerShell MVPs and PFEs @ Microsoft. Note: For more PowerShell best practices, check the PowerShellPracticeAndStyle github repository Start your scripts with a standard…


Dynamic ValidateSet in a Dynamic Parameter

A colleague of mine needed a way to have a parameter accept only a specific set of paths. I told him this can be accomplished easily with the ValidateSet decoration on the parameter, but he then explained that what the actually needed, is to have the set dynamically defined by the sub folders in the…


Get Excel data without Excel

In a specific scenario, I needed to be able to query an Excel file and get data from a worksheet but I didn’t (and couldn’t) have the Office suite (or even Excel only) installed on the machine. If the Excel file is and xlsx file (the new Microsoft Open XML Format since Excel 2007), you…


Set the Windows 7 user account picture

Not too long ago, I was asked if it's possible and how to set the Windows 7 user account picture (the one you see in the Start menu, and in the Lock screen) using PowerShell.There is no official documented way of doing it, but it can be accomplished quite easily using the SetUserTile static function…


Free PowerShell eBooks

last update: 2014/11/28 This (frequently updated) post contains links to useful and free PowerShell eBooks. If you have a suggestion for an eBook to be added to the list, please add a comment at the bottom of this post. The Altaro PowerShell Hyper-V Cookbook: Active Directory PowerShell Quick Reference: WMI query language (WQL) via PowerShell:…


Useful PowerShell Modules

2016-03-10 update: Using WMF 5.0 or WMF 3.0/4.0 with the PackageManagement and PowerShellGet modules, you can search for and install PowerShell modules from the PowerShell Gallery using the Find-Module and Install-Module cmdlets. Therefore, I will not be updating this post anymore. This (frequently updated) post contains links to useful PowerShell Modules. If you have a…


Write-Host “Hello World”

Hello world. My name is Martin, and I’ve been working in the IT industry for over 15 years, last 3 at Microsoft as a Senior Premier Field Engineer. What does a Premier Field Engineer (PFE) do? Read all about it here. Anyway, in this blog, I’ll be posting PowerShell tips I collect from the field….