Skip to main content

Using PowerShell to start the DFS Namespace service

· 3 min read

Distributed File System (DFS) has some service dependencies - so if those don't start the DFS Namespace service will also not start.

DFS Namespace

The dependencies are:

  • Remote Registry
  • Security Accounts Manager
  • Server
  • Workstation

I have seen the Remote Registry service become the culprit of the DFS-N service not starting.

In my experience, this had been caused by antivirus software changing the Remote Registry service to Disabled start-up type so when the DFS-N server restarts, one of the dependency services:

Remote Registry does not start so if you have issues with the DFS-N service not starting – check the Remote Registry Start-up type is configured to Automatic and click Start to confirm there are no errors and try starting the DFS-N service again.

Note: RemoteRegistry – although it is Automatic, will only Start when it is being used so don't be alarmed if it is in a 'Stopped' state.

Remote Registry

I have also created a PowerShell script to do some general checking for the DFS namespace service – which sets the Remote Registry service to Automatic startup then gets the other DFS dependency services and changes the startup type to Automatic and starts them and finally tries to start the DFS Namespace service.

Start-DFS.ps1

#requires -Version 2.0

<#
.SYNOPSIS
Starts the DFS service

.DESCRIPTION
Changes the Remote Registry service to Automatic start-up and Start the DFS NameSpace service dependencies, then start the DFS namespace service.
If the service does not start, it will retrieve the last 10 event log items from the DFS log.

.NOTES
Version: 1.0
Author: Luke Murray (Luke.Geek.NZ)
Creation Date: 20/03/17
Purpose/Change:
20/03/17 - Initial script development
11/06/18 - Updated script formatting

.EXAMPLE
./Start-DFS-Service.ps1

#>

#---------------------------------------------------------[Script Parameters]------------------------------------------------------

$ServiceName = 'DFS'
$ErrorActionPreference = 'Stop'

#-----------------------------------------------------------[Execution]------------------------------------------------------------

Try
{
Get-Service -Name RemoteRegistry | Set-Service -StartupType Automatic
}
Catch
{
Write-Verbose -Message 'There is an issue changing the Remote Registry Service to Automatic Startup Type' -Verbose
}
Try
{
$ServiceDependency = Get-Service -Name $ServiceName -DependentServices
$ServiceDependency | Set-Service -StartupType Automatic | Start-Service
Write-Verbose -Message "$ServiceName dependencies have started. Will now try starting the $ServiceName service.." -Verbose
}
catch [Microsoft.PowerShell.Commands.ServiceCommandException]
{
[Management.Automation.ErrorRecord]$e = $_

$info = New-Object -TypeName PSObject -Property @{
Exception = $e.Exception.Message
Reason = $e.CategoryInfo.Reason
Target = $e.CategoryInfo.TargetName
Line = $e.InvocationInfo.ScriptLineNumber
Column = $e.InvocationInfo.OffsetInLine
}
Write-Verbose -Message 'Opps! There was an error:' -Verbose
$info
}
Catch
{
Write-Verbose -Message "There was an issue starting $ServiceName dependencies" -Verbose
}

try
{
Try
{
Start-Service -Name $ServiceName
Write-Verbose -Message "The $ServiceName service has started." -Verbose
}
Catch
{
Get-WinEvent -LogName Microsoft-Windows-DFSN-Server/Operational | Select-Object -Last 10
}
}

catch
{
[Management.Automation.ErrorRecord]$e = $_

$info = New-Object -TypeName PSObject -Property @{
Exception = $e.Exception.Message
Reason = $e.CategoryInfo.Reason
Target = $e.CategoryInfo.TargetName
Line = $e.InvocationInfo.ScriptLineNumber
Column = $e.InvocationInfo.OffsetInLine
}
Write-Verbose -Message 'Opps! There was an error:' -Verbose
$info
}

Note: Script is also hosted on my Github repository. Feel free to clone/recommend improvements or fork.

Using PowerShell to connect to Microsoft Azure

· 2 min read

Microsoft Azure has a good user portal where you can do most things, however when it comes to automation, gathering a lot of information at once and more in-depth scenarios that the Portal doesn’t quite offer – PowerShell is used.

Before you can use PowerShell to connect to Microsoft Azure, you need to install the Azure Resource Manager modules first – follow the guide below:

Disable SMB1

Once the Az modules has been installed – you can now connect to Azure.

Usually you would have to go through the process of logging in to Azure, finding what subscription you need to connect to and then selecting that manually, however I have created a little function that will connect to Azure and automatically populate a list of the subscriptions that your account has access to in a window which you can then select to connect to which makes the process easier without having to remember different Azure subscription names or ids. This function can easily be used in any environment. I have it loaded as part of my PowerShell profile script so the function can be run from the second I open up a new PowerShell prompt.

Note: Script is also hosted on my Github repository. Feel free to clone/recommend improvements or fork.

Stuck at a Black Screen and Connecting on a vCloud console

· One min read

On a computer running Windows 7 x64 SP1 Enterprise running Internet Explorer 11 browser, I had issues connecting to the console of Virtual Machines hosted by VMWare vCloud.

vCloud Console black screen

This was resolved by completing the following:

  1. Adding the website to the Trusted Site list
  2. Adding the website to Internet Explorer’s compatibility list
  3. Updating Java on the workstation to the newest

Capturing Windows boot performance with the Windows Performance Toolkit

· 3 min read

The Windows Performance Toolkit, developed by Microsoft has 3 separate tools and are key to solving a lot of boot and general performance issues:

•    Windows Performance Recorder

•    Windows Performance Analyzer

•    Xperf

Download Windows Performance Toolkit

This can be downloaded by going to the Microsoft website and looking for the latest Windows Assessment and Deployment Toolkit for the operating system you want to analyze – for example: Windows 10

https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit

Download and run, we only need the Windows Performance Toolkit portion of the ADK:

Windows Performance Toolkit

Once installed navigate to: C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit

Tip: You can copy the Redistributables folder if you need to install the Windows Performance Toolkit only on another computer.

Run Windows Performance Recorder

We only need too: WPRUI.EXE – Windows Performance Recorder & WPA.EXE – Windows Performance Analyzer.

Run WPRUI to launch Windows Performance Recorder

Change the Performance Scenario to Boot, and File

Select Resource Analysis and click CPU usage

Tip: You can add more: File I/O, Networking I/O, GPU usage etc if you know what in particular may be causing your boot slowness, the more you add the more data and complexity is added. I would recommend to only add additional resource analytics when required.

Windows Performance Recorder

Click Start to select where your boot traces will go and click Ok to start your boot traces, this will restart your computer 3 times.

Tip: If you need to login, please make sure you login quickly during each trace as the longer you leave it unattended the more data and delay it will collect.

Run Windows Performance Analyzer

Once the computer has been restarted 3 times and your traces have been complete navigate back to: C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit and click on WPR.EXE to open the Windows Performance Analyzer or click Open in WPA from the Windows Performance Recorder dialog.

The Windows Performance Analyzer will be our canvas in analyzing issues, you can expand areas like System Activity to dig into Processes, Services. Just drag the data onto the Analysis screen to go through it

From here you can drill down into the data to find the cause or improvements for your login time, from here I can see one of the delays of my system is the CortanaUI.

I am running this on a 16GB i7 4GHZ machine running on an SSD so it isn’t really a good example, but have used this in the past to work out that my login was slow because Lync had logging turned on.

Hopefully this gets you through the first steps in diagnosis and resolving your performance issues.

Useful resources

Troubleshooting Windows Internals when unexpected events happen – https://channel9.msdn.com/events/Ignite/New-Zealand-2016/M405

Investigating website performance with Windows Performance Toolkit – https://github.com/MicrosoftEdge/MicrosoftEdge-Documentation/tree/master/performance-analysis/windows-performance-toolkit

Slow Boot Slow Logon (SBSL), A Tool Called XPerf and Links You Need To Read – https://blogs.technet.microsoft.com/askpfeplat/2012/06/09/slow-boot-slow-logon-sbsl-a-tool-called-xperf-and-links-you-need-to-read/

Database error when making changes to DHCP reservations

· One min read

'An error occurred while accessing the DHCP database.'

an error occurred while accessing the DHCP database

One of the issues I have ran into since an upgrade to Windows Server 2012 R2 DHCP servers – was due to multiple processes access the DHCP database when I was attempting to Create or Modify a DHCP v4 reservation.

  1. Adding an exclusion to DHCP.MDB file for Real Time scanning on my antivirus product.
  2. Disabling the Windows indexing service from indexing the DHCP folder.

To disable the Windows indexing service from indexing the DHCP server follow the quick steps below:

  1. Open Windows Explorer – or Computer: on the DHCP server
  2. Navigate to: c:\Windows\System32\DHCP
  3. Click on the General Tab up the top and click Advanced
  4. Uncheck ‘For Fast Searching, Allow Indexing Service to Index this Folder.’
  5. Click Ok

Useful Resources:

Microsoft Anti-Virus Exclusion List – https://social.technet.microsoft.com/wiki/contents/articles/953.microsoft-anti-virus-exclusion-list.aspx