Friday Fun: 13 More Scriptblocks

In celebration of Friday the 13th I thought I would offer up a menu of 13 more script blocks. If you missed the first course, you can find the original 13 scrptblocks here. I'm not going to spend a lot of time going over these. Many of them are simple one liners. Some of them take parameters just … Continue reading

PowerShell Scripting with [ValidateScript]

The last few days we've been looking at parameter validation attributes you might use in a script of function. Yesterday I wrote about [ValidateRange] and demonstrated how you might use it. That attribute works fine for any values that can be evaluated as numbers. But dates are a different story. … Continue reading

Scripting with PSCredential

I see this question often: how can I pass a parameter value for a PSCredential that might be a credential object or it might be a user name? In the past I've used code like this: begin { Write-Verbose -Message "Starting $($myinvocation.mycommand)" write-verbose -Message "Using volume … Continue reading

Re-Use PowerShell Scriptblocks

//Re-Use PowerShell Scriptblocks//I commented on a blog post today that showed how to use a hash table with Select-Object to format file sizes say as KB.dir $env:temp -rec | select fullname,@{Name="KB";Expression={$_.length/1kb}}Since you most likely will want to use something similar for … Continue reading