If you were sitting in my presentation last Tuesday, you may have caught my comment on some of the PowerShell-specific providers (Variable, Alias, Function) and how I haven’t really seen much use of them. While watching Allen White present on PowerShell and Policy Management in SQL 2008, I had a thought about this. I thought of a use for these providers What if you wanted to check to see if an alias existed before creating it? Same question for variables and functions…
We have the Test-Path cmdlet, so why not use Test-Path with these providers to see if the items exist before creating them?
While these are fairly primitive, they can work:
return Test-Path "alias:\$aliasname"
return Test-Path "function:\$functionname"
return Test-Path "variable:\$variablename"
Oh the random PowerShell thoughts that zip by…
Yesterday, I mentioned the Get-Verb cmdlet as a good one to know if you’re going to make your own cmdlets. Today, Matt is talking about all the good cmdlets. Really, he’s just getting your feet wet with a few cmdlets… our favorite cmdlets will come out throughout this series.
If you have any questions throughout this series, definitely leave us comments on our posts or email us. Matt and I love feedback, and despite this being a 31 days series, we may not like what we have picked for our topic of the day and may replace our pre-selected topic with something you suggest! You can email me at sarah at codinggeekette dot com.
I’ve recently found out that I’ve been selected to speak at devLink 2011. This is my 3rd year in a row speaking at devLink, and I’m incredibly honored to have been selected.
This year, I have 2 talks, and they are both on PowerShell! Tech editing and writing a PowerShell book really inspired me to continue to talk about it and get the word out. I used to spend a bit of time at the command prompt, and I love that I can bring .NET objects into a command prompt environment thanks to PowerShell.
My talks for devLink are:
Develop IT: Intro to PowerShell
This session is good for both developers and IT pros who want to get started with PowerShell but have not worked with it at all. In this session, we will look at the basics of PowerShell – from installation to grammar, aliases, piping, functions and profiles. We will use examples that are practical from both a developer’s point of view and from an IT professional’s point of view.
Develop IT: Extending PowerShell with Custom Cmdlets and Modules
This is the talk that debuted on 4/26 and will be custom tailored for devLink. PowerShell is a scripting language that takes advantage of working in a shell and being able to access .NET libraries. In this session, you will learn how you can write your own cmdlets to extend PowerShell to meet your business needs and distribute them in PowerShell 2.0, using your C# skills and Visual Studio 2010.
I hope to see some of you in Chattanooga at devLink 2011 this summer!