PowerShell tricks – Convert copied range from excel to an array of PSObjects

In this post, I would like to share a simple function that converts tables copied from Excel to the clipboard into PowerShell objects. While there are several more efficient ways to retrieve data out of Excel files (e.g. COM, EPPlus), I sometimes just want something quick and dirty to get the job at hand done. … Continue reading PowerShell tricks – Convert copied range from excel to an array of PSObjects

PowerShell tricks – Open a dialog as topmost window

Windows.Forms provides easy access to several built-in dialogs (see MSDN: Dialog-Box Controls and Components). Here is an usage example to show a "FolderBrowse" dialog: While this works as expected, the dialog won't show up as the topmost window. This could lead to situations where users of your script might miss the dialog or simply complain … Continue reading PowerShell tricks – Open a dialog as topmost window

PowerShell tricks – Use Show-Command to add a simple GUI to your functions

The Show-Command cmdlet has been introduced in PowerShell Version 3 and is very useful to help discovering and learning more about PowerShell cmdlets and their respective parameters (also built into the ISE as the Show-Command Add-on).: Show-Command can be also utilized for your own functions in order to provide your users with a simple GUI … Continue reading PowerShell tricks – Use Show-Command to add a simple GUI to your functions

PowerShell tricks – Useful default parameters to add to your profile

Since version 3 PowerShell introduced $PSDefaultParameterValues which is a built-in preference variable which lets you specify default values for any cmdlet or advanced function. You can read much more about it inside the respective help file. In a nutshell $PSDefaultParameterValues is a hash-table where (in its most common version) the key consists of the cmdlet … Continue reading PowerShell tricks – Useful default parameters to add to your profile

PowerShell tricks – Using dot(s) to refer to the current location

Most people are aware that PowerShell supports commandline navigation in the same way as the good old command prompt (see my previous post Improve PowerShell commandline navigation for ways to enhance this): The above is using cd as the alias for the Set-Location Cmdlet providing: One dot as an argument for the Path parameter representing … Continue reading PowerShell tricks – Using dot(s) to refer to the current location

PowerShell tricks – replace and transform a value within a string

Most PowerShell users know already of the String.Replace method and the PowerShell -replace operator. While the latter is quite powerful with its support for regular expressions ... : ... there is an even more powerful option available for cases where the characters that we want to replace need to be "transformed" in some way. Let's … Continue reading PowerShell tricks – replace and transform a value within a string

PowerShell tricks – Build an array of strings without quotation marks

This is one of the tricks I keep forgetting about and therefore document it here for myself but also in case someone else might find it useful. In order to create an array of strings one usually does something like this: It involves quite some redundant characters in order to do a simple thing. This … Continue reading PowerShell tricks – Build an array of strings without quotation marks