PowerShell: Why the Count Property or += Don’t Work Sometimes

One thing that I occasionally forget (and it can take me a while to remember the fix) is some apparently strange behaviour when processing an array.  Sometimes array-based methods don’t work when there’s only one item (or no items!) to be processed.

It’s all down to PowerShell’s automatic type conversion and is pretty easy to fix. Continue reading “PowerShell: Why the Count Property or += Don’t Work Sometimes”

PowerShell: Synchronizing a Folder (and Sub-Folders) Part 7

Hi. Here’s another update on the Sync-Folder script.  In this update Strict mode goes on, I make sure the statistics reset between runs, the Statistics output is rewritten and I add the option to only sync items that match a $Filter.

Update : I’ve revisited this script a few times with new additions and modifications.The latest full version of the script is here.  That post also includes links covering the other revisions to the script. Continue reading “PowerShell: Synchronizing a Folder (and Sub-Folders) Part 7”

PowerShell: Synchronizing a Folder (and Sub-Folders) Part 6

Hi. Here’s another update on the Sync-Folder script here.  In this part I add some more code to use literal paths (so that special characters don’t cause the sync to fail) and a report of the numbers of copies, updates, folder removals etc performed.

Update : I’ve revisited this script a few times with new additions and modifications.The latest full version of the script is here.  That post also includes links covering the other revisions to the script. Continue reading “PowerShell: Synchronizing a Folder (and Sub-Folders) Part 6”

PowerShell: Function to see if a Set of Properties Are on a Custom Object

I’ve been using scripts that pass loads of custom objects back and forth as function parameters.  In some cases these objects are built dynamically so they could have different properties on them.

It’s useful then to check if a particular set of parameters are on an object.

Hence;  this function!  (After the line!) Continue reading “PowerShell: Function to see if a Set of Properties Are on a Custom Object”