Archive | Windows Server 2008 R2 RSS for this section

Remotely set DNS Primary and Secondary Servers via PowerShell

Create a text file with a list of server names that you would like to change Primary & Secondary DNS for:

remotednschange1

 

#PowerShell Script:
$computer = get-content C:\temp\servers.txt
$DNSServers = “192.168.1.19”,”192.168.1.30″
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer |where{$_.IPEnabled -eq “TRUE”}
Foreach($NIC in $NICs) {$NIC.SetDNSServerSearchOrder($DNSServers), $NIC.SetDynamicDNSRegistration(“TRUE”)}

remotednschange2

Migrate 2008 DHCP to Server 2012 R2 with DHCP Failover

Recently needed to migrate an existing 2008 DHCP server to two new Server 2012R2 DHCP servers with Failover enabled.  Thankfully, this is a very straightforward process!

Logged onto to one of your new DHCP servers run the following PowerShell commands:

Export-DhcpServer –ComputerName OLDDHCPSERVERNAME.company.local -Leases -File C:\OLDDHCPSERVER-dhcpexp.xml -verbose

Import-DhcpServer –ComputerName NEWDHCPSERVER1.company.local -Leases –File C:\OLDDHCPSERVER-dhcpexp.xml -BackupPath C:\dhcp\backup\ -Verbose

Import-DhcpServer –ComputerName NEWDHCPSERVER2.company.local –File C:\OLDDHCPSERVER-dhcpexp.xml –ServerConfigOnly –verbose –BackupPath C:\dhcp\backup\

Note: If the C:\dhcp\backup\ path doesn’t exist you will need to re-run the command or create it first.

Next to enable the new failover functionality, right-click on your scope and select “Configure Failover.”
DHCP1
Specify “Hot standby” and specify your reservervation for standby server(this can generally be fairly low as clients will hold their lease for awhile.).  Specify a State Switchover Interval if you want your server to automatically failover after a period of disruption on the primary server.  Finally enable a Message Authentication Shared Secret if desired between the servers.
DHCP2

That’s it! 🙂

vCenter Service won’t start/Failed to create http proxy

I recently had a customer who’s vCenter service would not start on their management server.  The Event 1000 error showed: “Failed to intialize VMware VirtualCenter. Shutting down…”  Not very helpful!
Error1
Next, I checked the vpxd log files: %ALLUSERSPROFILE%\Application Data\VMware\VMware VirtualCenter\Logs\.  In there I noticed the following error: [VpxdReverseProxy] Failed to create http proxy: An attempt was made to access a socket in a way forbidden by its access permissions. This indicated that something was using one of the vCenter ports (By default 80,443,902).

Error2

The next step for this was to find out what was using one of those ports.  For that, we use the netstat command: netstat -bano > C:\netstat.txt (I will generally output this to text file as it makes it easier to search).
netstata
Search the output file for the ports VMware Ports listed above (or the non-standard ports you may have configured).
netstatb

To check what application is related to the PID, open Task Manager and add PID to the view (View, Select Columns)

TaskManagerPID
TaskManagerPID2

At this stage I had a pretty good idea what was using it.  Jumped into IIS and sure enough, somebody had started the Default Website running on Port 80. Stopped the website and restarted the vCenter Service with no further issues

IIS

services

Migrate DHCP Server in Windows Server

Quite often we will have a requirement for migrating DHCP between servers.  The process is very straightforward with 2008 & later servers.  First, install the DHCP Role onto your destination server if it’s not there already.  I find it easier to install this with PowerShell as opposed to Add Features as you don’t get all the prompts for setting scopes, etc.
From an elevated PowerShell, run Import-Module servermanager
DHCP-PS1

Next, install the role: Add-Windowsfeature DHCP -IncludeAllSubFeatures
#This will include the RSAT/Management Tools as well as the DHCP Service
DHCP-PS2

Next on your source server, right-click on your server and select “Backup”.  Save the backup file to a shared location.  Next select “Unauthorize” – this will allow you to authorize the migrated server.
DHCPa
On the new server, open DHCP, add your new server into the management view
DHCP-AddServer
Next, right-click on your new server and select “Restore”, select the backup file from your shared location and import.  Right-click on the new server and select “Authorize” and the server will now be ready to use.
DHCPb

Windows Server 2008 R2 not showing all available free space and won’t extend

We recently had an alert come through regarding one of our customer’s data drives running out of space.  I logged into to vCenter and extended the VM guest’s data drive, logged into Windows, ran DiskPart, selected the volume & extended it. This is generally my preferred method as more often than not it doesn’t show the space in Windows Explorer when the same process is ran from Disk Management.

diskpartlistvolume

diskpartextend

 

The extend showed that it completed successfully and all the available space showed up in Disk Management.  However it still wasn’t showing in Windows, even after a restart of the server.  Next thing I ran was extend filesystem on the selected volume.  This came back with the following error: DiskPart has encountered an error: The device does not recognize the command. See the System Event Log for more information.

 

dispartextendfilesystem

Researched the issue further and noticed that the Volume Shadow Copy Service was started, although there were not any scheduled Shadow Copies or Shadow Protect backups currently running.  Stopped the service and re-ran the extend in Diskpart – this time it completed with no errors and the correct space was then shown in Windows.
vssservice