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…

26

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…

17

Write to HKCU from the system account

In this scenario, I needed to be able to write to the currently logged on users’ HKCU registry, but from a process being run as local system. Afterwards I even had to write the HKCU for every user that will ever logon to the machine, and for every user that already logged-on before. The solution…

14

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:http://www.altaro.com/assets/Altaro-PowerShell-Hyper-V-Cookbook.pdf Active Directory PowerShell Quick Reference:http://www.jonathanmedd.net/wp-content/uploads/2009/10/ADPowerShell_QuickReference.pdf WMI query language (WQL) via PowerShell:http://www.ravichaganti.com/blog/wp-content/plugins/download-monitor/download.php?id=25…

10

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…

8

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…

8

Changing Shared Folders’ Path

As usual, the ideas for the posts start as a question from a colleague or a customer. In this case, the customer had to distribute differently the folders in his FileServers’ volumes. He had added an additional drive, copied all the relevant folders, and now needed to change the shares (non cluster resources) settings. If…

6

Filtering files by their metadata (extended properties)

When you run Get-ChildItem or any of its’ aliases, you’ll get back an array of objects, usually System.IO.FileInfo and System.IO.DirectoryInfo (if you have directories too). The properties displayed are Mode, LastWritetime, Length and Name. Of course there are other properties in the returned objects, but these are the ones that get displayed by default (more…

5

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….

5

Embed PowerShell code in a batch file

Embed PowerShell code in a batch file
Embed PowerShell code in a batch file

In a certain scenario, I needed a batch file (bat or cmd extension) that runs PowerShell code, and I could have only one file, so I couldn’t go with the easy way of a batch file calling PowerShell.exe with the -File parameter specifying the path to a ps1 file. For this, I created a special…

5