Archive for category administrator

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

List All Disks (VMDKs) In A Virtual Machine (ESXi)

Using VMware PowerCLI, PowerShell, there’s a nifty way to get a list of all VMDKs associated with a virtual machine(s).

Here’s the command:

Get-Vm | Get-Harddisk | Select Parent, StorageFormat, Filename, CapacityGB, Name | Export-Csv -Path C:\SomeFolder\SomeOutputFile.csv –NoTypeInformation
This command lists all VMDKs for all virtual machines in your VMware cluster.

For this sample, I chose to output the following fields:
Parent, StorageFormat, Filename, CapacityGB and Name

This sample code will provide you something like this:



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

Use the asset tag on a DELL Latitude E6500 as the computer name

Background

So I ran into an interesting bug with our DELL Latitude E6500 models and Microsoft’s SCCM 2012.

First off, in our environment we use the BIOS service tag information on all our DELL devices as the computer name in Windows 7. I’m able to get this information during the Task Sequence (TS) by means of using a VB script.

The script I mention above works on all our DELL computer and laptop models, with the exception of the DELL Latitude E6500 laptop models.

The Bug

On a DELL Latitude E6500, with the BIOS updated to the latest version, it looks like the BIOS asset tag information is somewhat misleading. If you view the information, you’ll see the asset tag information, but what you don’t see are the trailing spaces after the asset tag information. For instance, if the BIOS asset tag information on a laptop reads X1234, there are 5 trailing spaces after it, and these white spaces do not show!

Note: We use a tool called asset.exe, from DELL, to modify the asset information and the owner information in the BIOS. This tool works well on many of DELL computers and laptops.

SCCM 2012 and The Bug

During a SCCM Task Sequence (TS) job, we collect the asset information and we use this information as the Windows 7 computer account. The TS works perfectly until the last step: Setup is applying system settings – at this point, the TS fails with the message: Windows could not parse or process the unattend answer file for pass [specialize]


The TS fails completely and you’re left with a computer whose OS isn’t working.

SCCM logs give a hint on what went wrong. In case you don’t know, those logs can be retrieved from the broken machine and the logs (setupact.log and setuperr.log) are located at: C:\Windows\Panther\UnattendGC
In our case, both files showed the following error message:

2013-02-27 15:35:17, Error     [Shell Unattend] ComputerName: failed to set the computer name [hr=0x80070057][gle=0x00000057]
2013-02-27 15:42:30, Error    [windeploy.exe] Setup.exe failed, returning exit code [0x1f]
2013-02-27 15:42:30, Error     [windeploy.exe] Failure occured during online installation.  Online installation cannot complete at this time.; hr = 0x80004005
2013-02-27 15:43:42, Error     [windeploy.exe] Setup.exe failed, returning exit code [0x1f]
2013-02-27 15:43:42, Error     [windeploy.exe] Failure occured during online installation.  Online installation cannot complete at this time.; hr = 0x80004005


After reviewing this log, this pointed me to the VB script mentioned earlier and to the BIOS asset tag information. I knew the script was working properly, so I turned my attention to the BIOS asset tag information.
After several hours of toying around with asset.exe, I realized that there were blank spaces after the asset tag information – 5 spaces in total!

The Workaround (not a fix)

Basically, I used asset.exe and deleted the current asset tag and re-typed it, but this time I added 5 letters to the end. In other words, my command line looked like this:

asset.exe X1234ABCDE

X1234 is the asset tag information (a.k.a my Windows 7 computer name); however, ABCDE is the workaround to make sure those blank spaces don’t break the TS.

After the TS finished, then I logged on as a local administrator and renamed the computer name to X1234 – life is good again!

Note: During this entire troubleshooting process we updated the laptop BIOS, and this didn’t seem to fix the issue.

I hope this helps someone out there.

Leave a comment

Create New Local Administrator From Command Line

The following command line tools will allow you to:

  1. Create a new local user account
  2. Set the account from step 1 to password never expire
  3. Add the account from step 1 to the local “Administrators” group

net user /add

wmic useraccount where “Name=’‘” set PasswordExpires=false
net localgroup Administrators %computername%\ /add
I used these commands during a Task Sequence in SCCM 2012.

1 Comment