PowerShell: Fixing “Windows could not connect to the Group Policy Client service”

My wife got this error the other day on her Windows 10 machine when trying to login.  After a bit of digging, it seems it’s not unheard of but there’s no clear answer about why it happens (It’s a corrupted / missing set of registry entries.  The cause could be a bad shut-down, crash, interrupted update or pre-cursor to Martian attack.  Who knows.)

I found a good site that provides a solution. To fix the issue you need to create a registry sub-key and value (confusingly, both of the same name) and a pair of values under the sub-key you just created. That cures the problem but there’s no more information about to how to prevent it happening again.

In lieu of a proper preventative solution I wrote a script to perform the changes (with a bit of safety code too) so if it re-occurs I’m good to go.

Script and walk-through after the line. Continue reading “PowerShell: Fixing “Windows could not connect to the Group Policy Client service””

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

Some more additions to the script.  In this part I add some additional configuration options, parameter validation and some error-checking.

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

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

I’ve used the Sync-Folder script quite a bit and I thought it might be time to revisit it, clean it up and add some more functionality.

Here’s what I’m adding in this first part;

  1. Load all the configuration from an XML file.  Useful to allow more complex configurations and a lot easier to edit that parameters or local variables.
  2. Proper documentation (so that Get-Help returns useful information).
  3. Allow multiple Source / Target pairs instead of just the one source folder.   Multiple copies of the same source is good for extra safe backups.

The script and explanation follows after the line.

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

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”