Archive for category reboot

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

Deploying Oracle JAVA

As of JAVA 8 Update 73, this is the easiest way I’ve found to deploy JAVA on a corporate environment.

  1. Download JAVA from here
    1. You’re going to select the Windows Offline download option
  2. Take a look at the many installation options now available for the JAVA EXEcutable file, those options can be found here
  3. From an elevated command line, you’re going to run the JRE executable file with the options you select from step 2
    1. Here’s just a sample command line (all in one line):
    2. jre-8u73-windows-i586.exe EULA=Disable INSTALL_SILENT=Enable AUTO_UPDATE=Disable REBOOT=Disable REMOVEOUTOFDATEJRES=1
    3. You should be able to find the meaning of each installation option by reading the document in step 2. In essence, I’m installing JAVA and accepting the EULA, a silent install with JAVA auto update disabled as well as removing any outdated installations of JAVA and finally rebooting is disabled.

JAVA Instal

Note: Here’s a great JAVA 8 deployment blog in case you need other means of installing it

 

For those using System Center Configuration Manager 2012 (SCCM 20120), one of the ways to create an application deployment would be to use ‘manual’ deployment type and use a script to install JAVA. In the script I used, I was able to use START /WAIT command to execute the JRE file.

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