PowerShell Team

PowerShell Team, PowerShell

PowerShell is a task-based command-line shell and scripting language built on .NET. PowerShell helps system administrators and power-users rapidly automate tasks that manage operating systems (Linux, macOS, and Windows) and processes.

Post by this author

Debugging Monad Scripts, Part 5: Preferences and Commandline Options

Did your command or script fail and/or report an error?  We hope to have a proper script debugger in a future version, but until then, MSH has some handy features to help you figure out what went wrong.  In this series of blog entries, I will present some of those features.  Thanks to Jim Truher [MSFT], Bruce Payette [MSFT], ...

Debugging Monad Scripts, Part 4: set-mshdebug

Did your command or script fail and/or report an error?  We hope to have a proper script debugger in a future version, but until then, MSH has some handy features to help you figure out what went wrong.  In this series of blog entries, I will present some of those features.  Thanks to Jim Truher [MSFT], Bruce Payette [MSFT], ...

Debugging Monad Scripts, Part 3: Write-Host

Did your command or script fail and/or report an error?  We hope to have a proper script debugger in a future version, but until then, MSH has some handy features to help you figure out what went wrong.  In this series of blog entries, I will present some of those features.  Thanks to Jim Truher [MSFT], Bruce Payette [MSFT], ...

Debugging Monad Scripts, Part 2: $error

Did your command or script fail and/or report an error?  We hope to have a proper script debugger in a future version, but until then, MSH has some handy features to help you figure out what went wrong.  In this series of blog entries, I will present some of those features.  Thanks to Jim Truher [MSFT], Bruce Payette [MSFT...

Debugging Monad Scripts, Part 1: Teminating vs. Non-Terminating, ErrorRecord

Did your command or script fail and/or report an error?  We hope to have a proper script debugger in a future version, but until then, MSH has some handy features to help you figure out what went wrong.  In this series of blog entries, I will present some of those features.  Thanks to Jim Truher [MSFT], Bruce Payette [MSFT], ...

Image Conversion

  I needed to convert some images from bmp to gif for a web site I've been working on.  I figured that I could script this pretty easy - here's what I came up with.  It's a little more general than I needed, and I thought it might be useful to others.  Anyway, it's useful to me.      # Convert one graphic...

Duplicate Files 2

A long time ago I posted a filter (AddNote) for adding notes to objects.  Some time later I posted a function (Get-MD5) for calculating the MD5 hash of a file and somebody asked how that could be used in a script to list all the files in a given folder that are very likely the same.  I like that question because the answer it ...

Duplicate Files

Need a way to check if two files are the same?  Calculate a hash of the files.  Here is one way to do it:   ## Calculates the hash of a file and returns it as a string. function Get-MD5([System.IO.FileInfo] $file = $(throw 'Usage: Get-MD5 [System.IO.FileInfo]')) {   $stream = $null;   $cryptoServiceProvider = [...

Adding Notes

  A while back I mentioned that there was a way of adding notes to objects in the shell. Here is one way to do it: ## Adds a note to the pipeline input. filter AddNote([string] $name, $value) { $mshObj = [System.Management.Automation.MshObject] $_; $note = new-object System.Management.AUtomation.MshNoteProperty $name, $value $mshObj....

MshObject and Methods that take object

Every once in a while people ( including me) run into trouble calling methods that take object.  Why?  Well, as I told you earlier objects in MSH are wrapped by an invisible MshObject.  As it turns out that this invisible object is not always so invisible.  Take a look at the following:   MSH>$key = get-item . ...