PowerShell: Bulk Add/Remove Users From Groups
Oct15

PowerShell: Bulk Add/Remove Users From Groups

KB ID 0001475 Problem I had to do this a few weeks ago, so I documented it. I had a list of usernames in a CSV file and I needed to bulk-add them to a security group. Bulk Add Group Users Solution Firstly you will need the usernames (sAMAccountNames) in .csv format like so,  (Note: As a header Im using User-Name.) I’ve saved the file to C:\Temp on my server. Execute the following commands; Import-Module ActiveDirectory ...

Read More
PowerShell: Bulk Enable / Disable Users
Sep11

PowerShell: Bulk Enable / Disable Users

KB ID 0001469 Problem I needed to work out how to bulk disable some domain users from a .CSV file this week, so I thought I’d write it up. Disable Domain Users in Bulk from CSV Well firstly, you need to have your users in a CSV file. For the live job I just exported all the SamAccountNames to a CSV, but here for testing I just loaded a few in manually; Then execute the following two commands; Import-Module ActiveDirectory ...

Read More
Exchange and the LegacyExchangeDN Problem
Sep07

Exchange and the LegacyExchangeDN Problem

KB ID 0001468 Problem Why do we have the Exchange LegacyDN? It’s a throwback, from a time when we had our users, and our mail users in different databases. Below you can see the ExchangeLegacyDN for this Exchange on-premises user; /O=First Organisation/OU=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn={something-user-specific} Who cares? Well they are still important, if you send an internal email (to someone...

Read More
Forward Mail From Exchange (On-Prem) To Office 365
Sep06

Forward Mail From Exchange (On-Prem) To Office 365

KB ID 0001467 Problem WARNING: Do not do this, if you are carrying out a Hybrid migration to Office 365! I’ve been doing an On-Prem to Office 365 migration recently. It was a little unusual because the ‘on-prem’ Exchange was not in the clients domain. So rather than migrate all the mail to their domain, and them migrate it to Office 365  we chose to use a third party migration solution ODME (Quest On Demand Migration...

Read More
Exchange 2019 / 2016 Manage Remotely via PowerShell
Aug30

Exchange 2019 / 2016 Manage Remotely via PowerShell

KB ID 0001465 Problem Since Exchange 2013 we have been able to manage Exchange remotely through the Exchange Admin Center, but what if you want to use the Exchange Management Shell remotely? Install Exchange Management Tools This is not just the Management Shell, this will also install the Toolbox and additional help. There are few prerequisites, but to install from a normal PowerShell prompt; Enable-WindowsOptionalFeature -Online...

Read More
PowerShell: Cannot Be Loaded Because Running Scripts is Disabled
Mar24

PowerShell: Cannot Be Loaded Because Running Scripts is Disabled

KB ID 0001417 Problem If you’ve arrived here, you are trying to run a script, and you cant; PS C:\Users\{User-name}> .\{script-name}.ps1 .\{script-name} : File C:\Users\{User-name}\{script-name} cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1 + .\{script-name} + ~~~~~~~~~~~~~~~~~~ +...

Read More
Connect to Office 365 Exchange PowerShell
Mar14

Connect to Office 365 Exchange PowerShell

KB ID 0001410 Problem If there’s one thing thats grown on me it’s PowerShell, After the last few versions of Exchange you can’t really escape it. So now we have so many clients with their Exchange in Office 365. The ability to connect to that, and use all your usual Exchange commandlets is a bonus! WARNING: This process may end up with you getting an “Access is denied” error, if you are using modern...

Read More
PowerShell – Getting Server IP Address Information
Feb26

PowerShell – Getting Server IP Address Information

KB ID 0001404 Problem I’ve been rebuilding some Hyper-V hosts over the last few weeks, and one thing I learned rebuilding VMware ESX hosts is, ‘make sure you know what all the network cards are doing before you flatten it!’ The same is true of storage as well but here I’m just concentrating on networking. List Network Cards and MAC Addresses If you have these documented you can rename the network card correctly...

Read More
Remotely Log Users Off From CLI / PowerShell
Feb15

Remotely Log Users Off From CLI / PowerShell

KB ID 0001401 Problem I’ve not had to do this since the days we got “The terminal server has exceeded the maximum number of allowed connections” errors. Now thankfully Windows Server tells us who is logged on so we can ‘ask politely’ before we boot them off! Today though, my user session got all messed up, and I needed to kick ‘myself’ off remotely, (and have a fresh session.) Solution From a...

Read More
PowerShell: Creating Domains and Domain Controllers
Feb12

PowerShell: Creating Domains and Domain Controllers

KB ID 0001400 Problem I needed to spin up some Windows 2016 Servers, and a domain to do some testing. I have promoted hundreds maybe thousands of domain controllers, so I wondered if this time I could do it with PowerShell. It’s actually easier than using the GUI! Solution If you were doing this in Server Manager, you would have to add the role first, and PowerShell is no different; Install-WindowsFeature AD-Domain-Services...

Read More