For SPLA Licencing , we have to report the amount of users we have in AD, which can be quite a pain, the more ADs and OUs are there.

With this one-liner you can get those numbers quicker.

(Get-ADUser -Filter * -SearchBase "ou=<OuName>,dc=<DomainName>,dc=local").count

 


Some Hyper-V VM remote management commands:

For that to work right the VM has to be shut down.

Here a list of Hyper-V Commands
https://technet.microsoft.com/en-us/library/hh848559(v=wps.630).aspx

– Shut down VM

# Get VMs on Host
Get-VM
# Shutdown VM - Forcefully
Stop-VM –VMname <VmName> -Force

– Set the amount of Cores assigned to the VM

# Get all the VMs on the host
Get-VM
# Set the amount of assigned 
Set-VMProcessor -VMname <VmName> -Count 2 -Reserve 10 -Maximum 75 -RelativeWeight 200

– Set Amount of RAM assigned

# Get VMs installed on host
Get-VM
# Assign RAM to VM
Set-VMMemory -VMname <VmName> -DynamicMemoryEnabled $true -MinimumBytes 64MB -StartupBytes 256MB -MaximumBytes 2GB -Priority 80 -Buffer 25

– Start VM back up

# Start Virtual Machine
Start-VM -VMname <VmName>

 


Since we are still moving things, we had to update the home drive location.

  1. Get a list with all users who have a Home Drive set.
Get-ADUser -filter * -properties scriptpath, homedrive, homedirectory | ft Name, scriptpath, homedrive, homedirectory
  1. I cleaned the list out and saved it as a .txt file

  2. Then go through the list and update the Home Directory for each user in the list.

foreach ($SAM in Get-Content C:\HomeFolder.txt){
set-aduser $SAM -homedirectory \\<UpdatedPath>\$SAM -homedrive u:
}

 


We were moving data with a tool called Syncedtool. It works pretty good, however the biggest downfall is, it does not copy NTFS permissions… UGG!

So here my Batch fix for it. Since PowerShell is a pain to be used to that…

::Since it has multiple folders I need to replace, I put it in a loop
:start
::subinACL installs in that folder and has to be used from there
cd C:\Program Files (x86)\Windows Resource Kits\Tools
set /p folder=Set the Data Path:
::First we clean out all permissions and get rid of the faulty ones
subinacl /subdirectories D:\users\%folder% /perm
subinacl /subdirectories D:\users\%folder% /grant=system=F
subinacl /subdirectories D:\users\%folder% /grant=<user1>=F
subinacl /subdirectories D:\users\%folder% /grant=administrators=F
subinacl /subdirectories D:\users\%folder% /grant="Domain Admin"=F
::Here we grant the user of the folder access to his folder
subinacl /subdirectories D:\users\%folder% /grant="<domain>\%folder%"=F
subinacl /subdirectories D:\users\%folder%\* /grant="everyone"=F
echo Finished for %folder%
goto start

 


A quick rundown how to NIC Team in Server Core:

  1. We connect to the remote host and check what NICs are available to Team. We want to make a not of the adapter names.
# Connect to the remote host
Enter-PSSession <hostname>
# List all the physicak adapters available to the machine
Get-NetAdapter -Physical
  1. We create a new team and specify a name. Then we add NIC01 and NIC02 to the team.
# Create a team called "TestTeam" and add NIC01 and NIC02 to the team
New-NetLbfoTeam -Name TestTeam -TeamMembers "NIC01", "NIC02"
  1. Once we do that, the it will ask if it is ok and it will add the default settings:

_TeamingMode:’SwitchIndependent’ and LoadBalancingAlgorithm:’Dynamic’</p>

</em>TeamingMode

In this “Switch Independent Mode” the switches are not aware that different interfaces on the server comprise a team. Instead, all the teaming logic is done exclusively on the server.

There is also the option for “Switch Dependent Mode”, wherein all NICs that comprise the team are connected to the same switch for aggregation rather than redundancy.

**LoadBalancingAlgorithm</p>

— Dynamic:

</strong>Uses the source and destination TCP ports and the IP addresses to create a hash for outbound traffic. Moves outbound streams from team member to team member as needed to balance team member utilization. When you specify this algorithm with the TeamingMode parameter and the SwitchIndependent value, inbound traffic is routed to a particular team member.**

— TransportPorts:

** Uses the source and destination TCP ports and the IP addresses to create a hash, and then assigns the packets that have the matching hash value to one of the available interfaces. When you specify this algorithm with the TeamingMode parameter and the SwitchIndependent value all inbound traffic arrives on the primary team member.**

— IPAddresses:

** Uses the source and destination IP addresses to create a hash, and then assigns the packets that have the matching hash value to one of the available interfaces. When you specify this algorithm with the TeamingMode parameter and the SwitchIndependent value, all inbound traffic arrives on the primary team member.**

— MacAddresses:

** Uses the source and destination MAC addresses to create a hash and then assigns the packets that have the matching hash value to one of the available interfaces. When you specify this algorithm with the TeamingMode parameter and the SwitchIndependent value, all inbound traffic arrives on the primary team member.**

— HyperVPort:

** Distributes network traffic based on the source virtual machine Hyper-V switch port identifier. When you specify this algorithm with the TeamingMode parameter and the SwitchIndependent value, inbound traffic is routed to the same team member as the switch port’s outgoing traffic.

  1. Once that is done you should have a team
# Check on the NIC Team status
Get-NetLLBfoTeam

We can check which NICs are the member, the status it is in, if it is up , or degraded

(mine was degraded since I only connected one NIC :oP)

Sources:

– https://technet.microsoft.com/en-us/library/jj130849(v=wps.630).aspx

http://www.windowsnetworking.com/articles-tutorials/windows-server-2012/windows-nic-teaming-using-powershell-part1.html