Browsing the archives for the powershell tag.


The Perky One

Personal

From an article about a Katie Couric photo shoot for Harper’s Bazaar:

Couric calls herself a joyful person. "I mean, hello? Yes. I am. I am! And unashamed that I’m not cynical or dark or ironic."

I’ve never been the world’s biggest Couric fan, but her Sarah Palin interview from late 2008 cracked the ice, and now I find she’s an irrepressibly joyful person and I’m all agog and giggly and aw-shucks and toe-twistingly blushing over The Perky One.

I still won’t watch CBS Evening News, or any other network news show for that matter, because I loathe lowest-common-denominator sensationalism that deals almost exclusively with violence or hate or pain or anger or catastrophe or extremism, but the producers have the control over that stuff.

It’s been a good couple days.  My team completed the iteration in style, finishing all our commitments and making headway on some important analysis that put us in a good place during upcoming iterations.  I have a good team, and I am very lucky to work with them.

Gratitude is back on my mind again today – a random blog post elsewhere talked about it.  I ask myself am I expressing gratitude as much as I could? I don’t know, I guess that’s a never-ending question.  Plenty of people are deserving of my gratitude.  Thinking about it, I can think of times each day for the past few days where I’ve made special mention of someone who has done something nice or what have you.  Is it becoming second nature?  Would a friend describe me as someone who expresses well-deserved gratitude?  I hope so.

I’ve been doing some deep-dive exploration of PowerShell’s WMI provider and am thinking about adding yet more to my plate by doing a short series of blog posts for the smart-but-new-to-PowerShell developer about how to use WMI.  It’s powerful stuff.  And I’m guessing that those kind of posts will be hugely popular for the right search engine terms, because the current documentation is pretty thin.

Two people have told me that they felt “stalker-ish” by going to my blog to find out more about me.  I have to laugh – I put so much out there, that if I had any stalkers, they’d basically be able to find out anything they want, and know exactly where I go, almost all the time.  There is however, a part of me that occasionally wishes I could be even MORE open, MORE transparent, MORE clear – but there are some topics that are still taboo in this era where we expose almost everything.  Not to mention that if I write about it, it becomes more real, and sometimes I just want to forget, to move on, to seek out new worlds, to boldly go where no man has gone before…sorry, I digressed into a Star Trek moment there.  But writing-as-catharsis has a counterargument, writing-as-disguising-reality, and I don’t want to breathe life into something that’s bothering me by worrying it to death on these pages.  Maybe I’m bothered for no good reason, or I’m properly bothered and the appropriate response is just to ignore it and move on.  Blogging about it would just give it legs.

Which brings me to another recently reoccurring topic, Other People’s Comments.  I’m on much better terms today with a couple things that were said that hurt my feelings than I was, say, a week ago.  Stuff gets said.  Deal.  It helps when you realize that no malice was intended.

Big night of coding tomorrow night – wonder what coffee shop I’ll be at.  Probably Zoka, unless a better idea presents itself.  Then more work this weekend, intermixed with some time with the kids and (maybe) watching the Super Bowl.  Maybe I’ll look around for a Super Bowl party that a friend is already throwing and bring some chips and beer and Drew Brees jokes.

Wow, another novel!  Yay me. Thank you for reading. :)

1 Comment

Recursively Deleting SVN Folders in PowerShell 2.0

Software

I ran across this little nugget of PowerShell wisdom when working up a script to recursively delete those hidden .svn folders in your local working copy: PowerShell can make good use of parentheses.   And they’re sometimes necessary!  Consider the following two (almost identical) calls:

get-childitem -recurse -force | where-object { $_.PsIsContainer -eq $true -and $_.Name -eq ".svn" }  | remove-item –recurse –force

(get-childitem -recurse -force | where-object { $_.PsIsContainer -eq $true -and $_.Name -eq ".svn" } ) | remove-item –recurse -force

Very subtle difference: in the second one, I’m combining the pipelined directories obtained by the get-childitem call in parentheses BEFORE I pipeline it to the remove-item cmdlet.  This is the only way it will work properly.  The culprit?  The where-object filter, when left alone without parentheses, won’t pass the right objects to remove-item.  When put in parentheses with get-childitem, however, the where-object doesn’t pipe anything to anybody – it’s just filtering out the GCI data.

Hope this helps.

No Comments

How to Uninstall Windows PowerShell 1.0

Software

Having problems upgrading your old PowerShell 1.0 installation to the 2.0 CTP? The CTP won’t install until you’ve uninstalled all previous versions of PowerShell, but lots of people are having problems figuring out how to uninstall v1.0.

The official docs tell you to click on the “Show updates” checkbox in the Control Panel Add/Remove Programs applet, but that didn’t work for me. “Windows PowerShell 1.0″ (or any variation thereof) didn’t show up.

A google search led me to look for installed service packs in the %WINDOWS%\$NtUninstallKB* directories that has the “PSCustomUtil.exe” file in them. Then go to the child /spuninst/ directory and uninstall the KB that way. I got a ton of warnings saying I would nuke my system back to the Stone Age should I attempt the treasonous act of actually uninstalling a KB patch, but I – being the renegade that I am – went ahead and did it anyway.

My search picked up two KB packs: KB926139-v2 (Windows PowerShell 1.0), and KB926141 (Windows PowerShell MUI).

Once I uninstalled both, I was able to successfully install the PowerShell v2 CTP3.

Hope this helps you too.

7 Comments

PowerShell 2.0 CTP: How to find static members

Software

This one stumped me for a minute – how do you find static members of a given type? Get-Member by default only shows the instance members.

The trick is to use the flag -static with Get-Member, to tell PowerShell that you want only static members.

Example:

[Convert] | gm -static

No Comments

PowerShell 2.0 CTP: How to get the types for a given namespace

Software

This handy little trick allows you to find out all the types that are defined for a specific namespace. If, like me, you’re using PowerShell to interact with custom DLLs, quite often you have hundreds of types defined. This script (and its variations) allows you to narrow down the list a bit when you’re searching.

var $dll = [Reflection.Assembly]::LoadFrom("$pwd\your.dll")
$dll.GetExportedTypes() | ? {$_.Namespace -eq "Your.Namespace" } | select Name, Namespace

No Comments

PowerShell Community Extensions for PowerShell 2 CTP 3

Software, Uncategorized

PowerShell Community Extensions:

is aimed at providing a widely useful set of additional cmdlets, providers, aliases, filters, functions and scripts for Windows PowerShell that members of the community have expressed interest in.

Short answer: you want this, if you’re a PowerShell user. However, there are some initial gotchas that may cause you problems. I’m running Windows Vista Ultimate 32-bit, and had to do a bit of tweaking to get the install working properly. Here are the notes from my session:

First, go to the PSCX website to get the latest download (version 1.1.1 at the time of this writing).

Next, run the following script one time in the ISE:

$path = "$((get-pssnapin -r pscx).applicationbase)\typedata\filesystem.ps1xml"
$config = [xml](gc $path)
$config.Types.removechild($config.Types.Type[1])
$config.get_outerXML() > $path
update-typedata

Close the ISE and relaunch it.

You’ll see a bunch of errors like the following:

Set-Alias : Alias is not writeable because alias measure is read-only or constant and cannot be written to.

For some reason, some of the PSCX aliases are set to read-only and need the -Force parameter to get them to work.

Instructions for fixing each of the issues:

C:\Program Files\PowerShell Community Extensions\Profile\GenericAliases.ps1
Line 8
Set-PscxAlias measure MeasureObject -Force

C:\Program Files\PowerShell Community Extensions\Profile\PscxAliases.ps1
Line 28
Set-PscxAlias start Start-Process -Force

C:\Program Files\PowerShell Community Extensions\Profile\Debug.ps1
Line 72
set-alias gcs Get-CallStack -Option AllScope -Description "PSCX function alias" -Force
Line 89
set-alias ebp Enable-Breakpoints -Option AllScope -Description "PSCX function alias" -Force
Line 103
set-alias dbp Disable-Breakpoints -Option AllScope -Description "PSCX function alias" -Force

No Comments

Excellent PowerShell ISE functions

Software

If you’re looking for a good set of prebuilt functions with which to extend your PowerShell v2 ISE environment, check out this excellent collection of PowerShell file, function, and module functions by Josh Einstein. It includes:

Open-File (opens a file in the ISE editor)
Open-Profile (opens your profile(s) in the ISE editor)
Open-Module
Open-Function
Close-File

http://einsteintech.spaces.live.com/Blog/cns!89E05724AF67A39E!724.entry?wa=wsignin1.0&sa=177582322

No Comments