Skip to content

Instantly share code, notes, and snippets.

@skylock
Last active November 27, 2017 12:16
Show Gist options
  • Save skylock/4814e35054d45fed32d9 to your computer and use it in GitHub Desktop.
Save skylock/4814e35054d45fed32d9 to your computer and use it in GitHub Desktop.
# Install Telenet Client
dism /online /Enable-Feature /FeatureName:TelnetClient
# Install Telenet Client Deploy .NET Framework 3.5
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
#Allow DPM Agent Push
netsh advfirewall firewall add rule name="Allow DPM Remote Agent Push" dir=in action=allow service=any enable=yes profile=any remoteip=192.168.100.15
# Fix for The WS-Management service cannot process the request
Register-PSSessionConfiguration -Name Microsoft.PowerShell
# Credentials in script
$secpasswd = ConvertTo-SecureString "vagrant" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("vagrant", $secpasswd)
#Connect network drive
net use \\sto01.ad.temasoft.com /user:temasoft\maniax P@ssword1
# Switch form 2012R2 Standard to Datacenter
dism /online /set-edition:ServerDatacenter /productkey:<Product key> /AcceptEula
# Get a list of trusted hosts
Get-Item WSMan:\localhost\Client\TrustedHosts
# Note that these commands don't create a list of trusted hosts, it simply replaces the trusted host with what you set via the command. If you need to add multiple hosts, they need to be comma seperated
# Trust all computers in a domain
Set-Item WSMan:\localhost\Client\TrustedHosts *.contoso.com
# Turst a single machine
Set-Item WSMan:\localhost\Client\TrustedHosts -Value myserver
# Add another single machine
$trustedHosts = (Get-Item WSMan:\localhost\Client\TrustedHosts).value
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$trustedHosts, mynextserver"
# Trust an IP address range
Set-Item WSMan:\localhost\Client\TrustedHosts -value 192.168.10.*
# Trust all remote machines (not recommended)
Set-Item WSMan:\localhost\Client\TrustedHosts *
# Enable RDP
--------------------------------
#Enable Remote Desktop
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
#Allow incoming RDP on firewall
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
#Enable secure RDP authentication
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1
#Run PS script from online source
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/skylock/packer-windows/master/scripts/configwinrm.ps1'))
# Set Network Connection Profile Windows 7 & 2008 R2
$networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
$connections = $networkListManager.GetNetworkConnections()
# Set network location to Private for all networks | 0 - Public | 1 - Private | 2 - Domain
$connections | % {$_.GetNetwork().SetCategory(1)}
# Set Network Connection Profile Windows 8.1 & 2012 R2
Get-NetAdapter | Set-NetConnectionProfile -NetworkCategory Private
# Clear all event logs
--------------------------------
wevtutil el | Foreach-Object {wevtutil cl "$_"}
# Exchange Powershell
--------------------------------
get-user | where-object{$_.RecipientType -eq "User"} | Enable-Mailbox -Database "servername\Mailbox Database" | get-mailbox | select name,windowsemailaddress,database
get-user -organizationalUnit Accounting | where-object{$_.RecipientType -eq "User"} | Enable-Mailbox -Database "servername\Mailbox Database" | get-mailbox | select name,windowsemailaddress,database
Temasoft-MailboxDatabase
get-user | where-object{$_.RecipientType -eq "User"} | Enable-Mailbox -Database "MTA01\Temasoft-MailboxDatabase" | get-mailbox | select name,windowsemailaddress,database
get-user -organizationalUnit Accounting | where-object{$_.RecipientType -eq "User"} | Enable-Mailbox -Database "MTA01\Temasoft-MailboxDatabase" | get-mailbox | select name,windowsemailaddress,database
# Hyper-V Linked Clones
-------------------------------
# Create the VM (with no VHD at this stage)
New-VM –Name DC02 -Generation 2 –MemoryStartupBytes 1024MB -SwitchName “Core vSwitch” -Path D:\Hyper-V\ -Verbose
# Create our New Differencing Disk
New-VHD –ParentPath "e:\Templates\Syspreped\Windows.Server.2012.R2\Virtual Hard Disks\Windows.Server.2012.R2.vhdx" -Path "D:\Hyper-V\DC02\Virtual Hard Disks\DC02-DiffDiskVM.vhdx" -Differencing
# Attach this Disk to the VM
Add-VMHardDiskDrive DC02 -Path "D:\Hyper-V\DC02\Virtual Hard Disks\DC02-DiffDiskVM.vhdx" –ControllerType SCSI -ControllerNumber 0
# Start VM
Start-VM DC02
--------------------------------------
# Test netwok performance
To generate large amounts of network traffic I used the iperf tool running on two virtual machines, one iperf “client” and the other as “server”.
I have found that the following iperf settings generates the best combination for network throughput tests on Windows Server:
Server: iperf -s -w 64k -l 128k
Client: iperf -c <SERVER-IP> -P 16 -w 64k -l 128k -t 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment