How to quickly create Active Directory OUs In Powershell

$domain = get-addomain | select -expand distinguishedname $facilities = “facilityname” $OUS = “Groups”,”Kiosks”,”Laptops”,”Users”,”Workstations” foreach ($facility in $facilities) { New-ADOrganizationalUnit “$facility” foreach ($OU in $OUS) { NEW-ADOrganizationalUnit “$OU” –path “OU=$facility,$domain” } } A very simple script I made to quickly create some OUs with sub-OUs inside. Basically all I need to add is facility names and …

Powershell – Quickly Create VMs with Differencing Disks, and then edit them!

I’m playing with a new storage backend so I wanted to create a whole bunch of VMs, then edit them, then stop them, then start them. Here’s how I did it. Here’s the end result. Now here’s how I did it. $value = 1..10 $vmstore = “C:\VMDATA\VM POOL\” $vmparent = “C:\VMDATA\VM POOL\Server 2012R2 Parent.vhdx” foreach ($number …

Moving DHCP from Server to Server with Powershell

My scenario: I needed to move DHCP from server 2012 to server 2012 R2 with leases. I wanted to do this quickly and safely. You can run all of these commands from your new DHCP server: Install DHCP + MGMT tools on the new server. Install-windowsfeature DHCP -includemanagementtools Authorize the new server Add-DhcpServerInDC Backup the …

Vultr.com Module for Powershell | Create, Stop, Start, Restart, and Destroy Virtual Machines!

My beta  module so be gentle, I will definitely be going back  and redoing the code. However right now it does work for up to 5 VMs. It basically uses invoke-webrequest instead of having to download curl for Windows. A fun learning experience that I will definitely be going back to perfect and fix. Download …

Powershell – Manipulating objects to pass them along the pipeline

Before getting into this, I’d like to discuss the pipeline a bit. In the pipeline you have to ways of passing objects, by value (typename) or by property name (which is powershell’s second try)   For example, let’s see what kind of objects get-process creates by piping get-member to it (I use the alias GM) …

How to Force Users in OU to Change Password at Next Logon via Powershell for Active Directory

  My goal is to to force all users in  a certain OU to change their passwords at next login. So let’s get started. First I need to get a list of my users accounts. We know we can use get-aduser -filter * to get all the users and their properties, however I only want …