In the previous tip we showed how you can use the PowerShell command mode to easily create lists of quoted strings. This can be really useful for creating code, and saves a lot of typing.

Here is a function that can help in everyday PowerShell coding life:

function s+ { "'$($args -join "','")'" | Set-ClipBoard }

Next time you need a list of quoted strings in your code, simply type:

 
PS> s+ start stop pause end whatever
 
PS> 'start','stop','pause','end','whatever'
start
stop
pause
end
whatever
 
PS>
 

The quoted strings are then available in your clipboard, and you can paste them into your code wherever needed.

Are you an experienced professional PowerShell user? Then learning from default course work isn’t your thing. Consider learning the tricks of the trade from one another! Meet the most creative and sophisticated fellow PowerShellers, along with Microsoft PowerShell team members and PowerShell inventor Jeffrey Snover. Attend this year’s PowerShell Conference EU, taking place April 17-20 in Hanover, Germany, for the leading edge. 35 international top speakers, 80 sessions, and security workshops are waiting for you, including two exciting evening events. The conference is limited to 300 delegates. More details at www.psconf.eu.

Twitter This Tip! ReTweet this Tip!

Anonymous