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

I wrote about a script to synchronise the contents of one folder to another here.  It worked as a quick and simple backup script and it would replicate files, deletions and sub-folders.  I’ve used it quite a bit since that post and I’ve made some special modifications myself.

Details after the break.

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 2”

PowerShell: Report Mailbox Delegates Script (Office 365 Migration Tool) Part 2

This is the second part (part 1 here, final part here) describing my script that enumerates delegates on mailboxes from a set of users.  This part looks at the first of the two main functions that do all the work.

Having looked through the script, there may well be better / cleaner ways of doing this;  but I’m publishing this ‘as is’ while remembering writing this on the fly with a curious customer in one ear and a hasty Project Manager in the other 🙂 Continue reading “PowerShell: Report Mailbox Delegates Script (Office 365 Migration Tool) Part 2”

PowerShell: Report Mailbox Delegates Script (Office 365 Migration Tool) Part 1

For these posts I’m going to break down a script I used in anger on a customer site.  I was helping them with an Office 365 migration from on-premise and one of the tasks they wanted help with was planning the order of the migration for their users.

One of the limitations of the migration is that delegate access didn’t work between on-premise and Office 365;  this meant you wanted users with delegate access to mailboxes to be moved with those mailboxes (like a manager with her assistants for example).

They had a large, organically-grown Exchange infrastructure.  This was another way of saying they had no idea who had access to who’s mailbox and also who was a manager of whom.  Time for a bit of PowerShell to save the day. Continue reading “PowerShell: Report Mailbox Delegates Script (Office 365 Migration Tool) Part 1”

PowerShell: Shutdown Azure VMs Outside Working Hours

I run some Azure Virtual Machine’s for work stuff (testing, remote access) and non-work stuff (game servers).  The specification is pretty low but I like to shut it down from Azure to reduce any charges from it.  This might lose their currently allocated IP address (they might get a different one on restart) but that’s not an issue for me.  Over the weekend is a good time as I almost never use Azure then.

Unfortunately my memory is pretty rubbish especially during the Friday afternoon excitement/rush.  What I want is a script that will run on my home machine, check the time and then shut my VMs down if we’re out of working hours.

The script follows with the explanation afterwards. Continue reading “PowerShell: Shutdown Azure VMs Outside Working Hours”

PowerShell : Find all Files Owned By A User

The Windows 10 release is just around the corner and I’m going to do a fresh install on a new hard-drive.  I’ve redirected most of my working directories to network locations so most of my files should just appear ‘auto-magically’ but I’m sure there’s a few files dotted around the place that are important that I’ve just ‘temporarily’ left outside one of the redirected folders.

So what I want is some PowerShell to find all the files owned by me on my hard-drives.  I can do this with a one-line PowerShell command as follows; Continue reading “PowerShell : Find all Files Owned By A User”

PowerShell : Renaming And Sorting All My Music Files

We have a large collection of MP3s and FLACs and most of the time they all work great.  I’ve spent quite a bit of time getting their metadata correct so the various players we have all play them in the correct order as they use their Disc and Track number metadata to sort them.

However my wife’s and I’s cars both can read music from SD cards.  This is great as they’re a lot faster to process than phone libraries over Bluetooth but the downside is that the only sorting they do is via the filename.  This means every album plays it’s tracks in alphabetical order.

Ideally to fix this what I want is a script to rename each music file according to it’s Disc Number, Track Number and Title metadata.  The script I wrote to do exactly that follows, with some explanations after. Continue reading “PowerShell : Renaming And Sorting All My Music Files”

PowerShell : Finding Duplicate Files, Part 3 : A Resumeable Script Using Workflow

In the the previous part we looked at making the original script survive a restart without losing progress. There is actually a built-in PowerShell system which allows this functionality, the workflow. If you run a workflow as a job it allows you to pause, resume and restart the workflow so progress is saved.

The syntax is pretty straight-forward, but there are some strange rules about using workflows which makes it a little more tricky. Continue reading “PowerShell : Finding Duplicate Files, Part 3 : A Resumeable Script Using Workflow”

PowerShell : Finding Duplicate Files, Part 2 : A Resumeable Script

The main issue I had with my original script here was that with the sheer number of pictures we had it didn’t finish in a reasonable time.  What I needed was a way to allow the script to work and resume from an interrupt (like a reboot).  So I took the original script and whacked it with the ScriptHammer(TM) again.

Updated script after the jump with notes following!

Continue reading “PowerShell : Finding Duplicate Files, Part 2 : A Resumeable Script”