Archive for category management

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

Install Hyper-V Role to Windows Server 2012 R2 During OS Deployment

There are plenty of blogs about this subject, however, many of these blogs are outdated and some of their tips do not work properly for Windows Server 2012 R2. Also, in my case, I’m not using MSDT to install features and roles, but instead I’m using a captured WIM image.

To install Hyper-V role, just add a “Run Command Line” task, towards the end of the task sequence, Install Operating System task.

I’m using the following PowerShell command:

Powershell.exe -Command "&amp; {&amp;'Install-WindowsFeature' –Name Hyper-V -IncludeManagementTools -Restart}"


Also, here’s an interesting link that discusses this particular issue.

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
$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)
$excelWorksheetColumns.Cells.Item($excelWorksheetRow, 3) = $date.GetVarDate($False)

# move to the next Excel rows by 1
$excelWorksheetRow = $excelWorksheetRow + 1
# 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

View the last time a computer was rebooted.

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.


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

Leave a comment