Coding Geekette

100% girl geek, all the time

PowerShell-Specific Providers, a Followup to 4/26

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:

function Test-Alias($aliasname){
    return Test-Path "alias:\$aliasname"
}

function Test-Function($functionname){
    return Test-Path "function:\$functionname"
}

function Test-Variable($variablename){
    return Test-Path "variable:\$variablename"
}

Oh the random PowerShell thoughts that zip by…

2 Comments »

This One Time in a PowerShell Session…Part 3 of 31: Where Did All the Good Cmdlets Go?

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.

No Comments »

This One Time in a PowerShell Session…Part 2 of 31: The Basics on How to Read PowerShell

Yesterday, I mentioned that I liked the Verb-Noun naming of PowerShell commands. Today, Matt is writing about The Basics on How to Read PowerShell, which explains these nouns and verbs. He’ll cover some quirks with them. He also talks about case sensitivity.

I only have one other tidbit to share. Matt mentions the verbs that are used, but he doesn’t tell you how he got those verbs. In PowerShell, there’s a Get-Verb cmdlet that lists the approved verbs. If you find yourself writing cmdlets (which we’ll talk about later), then you’ll want to remember this cmdlet.

No Comments »

PowerShell Not Your Father’s Command Line…

Throughout this month, my amazing coauthor Matt Hester and I will be taking you on a journey through our favorite tool at the moment – PowerShell! We’ll cover some things that we talk about in our book that’s due out May 16th, in addition to some things that aren’t in the book but still make for great points. (And yes, we’re taking a page out of Jeff Blankenburg‘s book and writing a “31 Days” series.)

Originally, Matt titled the series “PowerShell Not Your Father’s Command Line”, but he caught wind of one of my goofy Facebook statuses (This one time, at a command prompt…) and I suggested we rename it to “This One Time in a PowerShell Session…”.

Edit on 5/3 – Looks like Matt’s IT influencers voted on the previous series name, so they’re going back to the Not Your Father’s title.

I will try to keep this list updated as we post our days. We hope you enjoy our series!

Get-Popcorn. Get-Soda. Get-Chair. Read-Series!

No Comments »