Archive for category Windows Server 2008

Forcibly Remove Dfs Nameserver

The following steps can be used to remove a Dfs nameserver that no longer exists in your environment.

  1. Log on to a Dfs server
  2. Open an elevated command line
  3. We’re going to use dfsutil with the following parameters:¬†dfsutil diag unmapdomroot \<domainname><DFSname> \<DFSrootserver><DFSshare>
    1. As a sample: dfsutil diag unmapdomroot \\DfsRootName\DfsFolderName \\Server_to_remove\DfsFolderName
  4. No need to reboot just wait for replication

Leave a comment

Renaming Windows Domain Controllers

The following are the steps needed to rename a domain controller; the steps have been tested up to Windows Server 2016.

Note: If your DC is also acting as a Dfs nameroot server, make sure you remove the nameserver from Dfs first!

From an elevated command line, type the following commands:

  1. Add the new domain controller name NEW_DC; we’re replacing OLD_DC
    NETDOM COMPUTERNAME OLD_DC.companydomain.com /ADD:NEW_DC.companydomain.com
  2. Designate the new name as the primary computer name; OLD_DC gets removed and NEW_DC is new primary name
    NETDOM COMPUTERNAME OLD_DC.companydomain.com /MAKEPRIMARY:NEW_DC.companydomain.com
  3. Reboot domain controller
  4. Now, let’s remove the old domain controller name from Active Directory
    NETDOM COMPUTERNAME NEW_DC.companydomain.com /REMOVE:OLD_DC.companydomain.com
  5. Sync all DCs

In the event that you didn’t notice the warning on top and you went ahead and renamed the domain controller and you had Dfs services running on it, here are some instructions on how to manually remove Dfs nameserver¬†and fix the issue.

  1. Log on to the recently renamed domain controller
  2. Open Regedit.exe
  3. Go to HKLM\Software\Microsoft\DFS\Roots\domainV2
  4. Delete the key found under domainV2 and reboot your server
  5. Next, remove the Dfs share from the server
  6. Now you can delete the Dfs folder
  7. Done

2017-06-10_1708

Leave a comment

Get Active Network Adapter

Recently I had the need to create a script to find out what was the active network adapter in our server, so after some ideas from the web, I came up with a one line PowerShell script that helped me achieve my goal.

Note: Get-NetAdapter is a PowerShell commandlet that’s present on Windows 8 and Windows Server 2012 R2. This command will not work on Windows 7.

Get-NetAdapter | Where-Object {($_.LinkSpeed -eq “1 Gbps”) -and ($_.Status -eq ‘Up’)}

In this line, I’m basically getting the adapter with status ‘Up’ and with a linkspeed equals to ‘1 Gbps’. One can change LinkSpeed property to match your server’s network adapter speed(s).

Leave a comment

Last Server Reboot

I had a need to find out when was the last time my Windows servers were rebooted, so I found a piece of PowerShell code that I modified to suit my needs.


This piece of code has been greatly modified from the original.

This code has the following requirements:
  1. Excel must be installed on the computer running the script
  2. You will need server admin access to perform query
  3. A text file with a list of servers, no need to add \\ before server name


<# read parameter and assign it to $textFile
we're only expecting one parameter, which is the path to a
file containing a list of server/computer names #>

$textFile = $args[0]

# Let's make sure the file actually exists
If (($textFile -ne $null) -and (Test-Path $textFile))
{
# Create an Excel object file to show output
$excelApp = New-Object -comobject Excel.Application
$excelApp.visible = $True

$b = $excelApp.Workbooks.Add()
$excelWorksheetColumns = $b.Worksheets.Item(1)

$excelWorksheetColumns.Cells.Item(1,1) = "Server"
$excelWorksheetColumns.Cells.Item(1,2) = "IP Address"
$excelWorksheetColumns.Cells.Item(1,3) = "Last Boot Time"

$d = $excelWorksheetColumns.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit()
$excelWorksheetRow = 2

# read the contents of the file
$fileContents = Get-Content $textFile

ForEach ($computerName in $fileContents)
{
# if server is IP Enabled, we're going to get DNS Host Name and its IP Address
$networkAdapterConfiguration = Get-WmiObject Win32_NetworkAdapterConfiguration -computername $computerName | Where {$_.IpEnabled -Match "True"}

# collect and display, to Excel sheet, server's FQDN and IP address
ForEach ($detailsNetworkAdapterConfiguration in $networkAdapterConfiguration)
{
$excelWorksheetColumns.Cells.Item($excelWorksheetRow, 1) = $detailsNetworkAdapterConfiguration.DNSHostName
$excelWorksheetColumns.Cells.Item($excelWorksheetRow, 2) = $detailsNetworkAdapterConfiguration.IPAddress
}

$date = New-Object -com WbemScripting.SWbemDateTime
$computerOsInfo = Get-WmiObject Win32_OperatingSystem -computername $computerName

ForEach ($memberComputerOsInfo in $computerOsInfo)
{
$date.value = $memberComputerOsInfo.lastBootupTime
If ($memberComputerOsInfo.Version -eq "5.2.3790" )
{
$excelWorksheetColumns.Cells.Item($excelWorksheetRow, 3) = $date.GetVarDate($True)
}
Else
{
$excelWorksheetColumns.Cells.Item($excelWorksheetRow, 3) = $date.GetVarDate($False)
}
}

# move to the next Excel rows by 1
$excelWorksheetRow = $excelWorksheetRow + 1
}
}
Else
{
# Checking user input and displaying a warning if no proper syntax was used
Write-host "`nPath was not found, or no parameter was used.`nPlease run: Get-Help Get-LastReboot" -ForegroundColor Yellow
}

<#
.SYNOPSIS
View the last time a computer was rebooted.

.DESCRIPTION
This script will display the last time the computer was rebooted.
The script will require one parameter, the path to the text file containing the list of computer names.

.LINK
Get-LastReboot

.EXAMPLE
Example 1 - Simple use
Get-LastReboot C:\SomeFolder\ListOfServers.txt
#>

Leave a comment

No OST for Outlook 2010 on a Terminal Server

We had installed Microsoft Office 2010 on our Windows 2008 R2 Terminal Servers, and we didn’t customize the Office 2010 installation. I was looking for a way to prevent Outlook from generating a new OST file whenever a new user logged on to our Terminal Servers, in addition, I wanted the Outlook profile to be generated automatically.

Enter Group Policy Objects!

Since these policies are applied only for the TS servers, I moved the the computer accounts to a new Organization Unit (OU) that I created for these servers. I linked the new GPO to this OU. There are many documents that show how to do these steps, so I won’t be going over this.

The key point to remember for this GPO to work is: loopback processing mode

The above is true especially if your TS servers inherit policies from top level GPOs.

In my case, I was concerned about making changes to the user configuration section, to be more specific, to the Outlook 2010 settings.

The screenshot basically shows what needs to be done in order to achieve this goal.


1 Comment

From a GUID to its GPO name.

Numerous times I had the issue, when troubleshooting a group policy object error, in which I only had the GPO’s GUID, but not its actual name. Well, it turns out that there is a powershell applet that performs a search in AD, using the GUID, and it returns the GPO’s full description for you.

  1. Open Widnows PowerShell Modules
  2. Type: get-gpo
  3. Paste that GUID and press ENTER


Leave a comment