Archive for the 'Windows Server 2008' Category

Windows Server 2008 User Account Control Gotcha #2

Yesterday I blogged about some of the confusion that Windows Server 2008 User Account Control can cause.  Continuing on the same theme, here is another example - this time using slmgr.vbs to query the licence activation status of a Windows Server 2008 machine.

This is what you see when you run the command line from a command window that was opened without elevated privileges.

cscript %windir%\system32\slmgr.vbs -dli

Name: Windows Server(R), ServerStandard edition
Description: Windows Operating System - Windows Server(R), VOLUME_KMSCLIENT channel
Partial Product Key: BFGM2
License Status: Licensed
Volume activation expiration: 250200 minute(s) (173 day(s))

Key Management Service client information
    Client Machine ID (CMID): 3af05e3c-b291-47ad-bbf9-cc6278b3c923
    DNS auto-discovery: KMS name not available
    KMS machine extended PID: 55032-00152-339-003838-03-5129-6001.0000-0062009
    Activation interval: 120 minutes
    Renewal interval: 10080 minutes

As you can see, the name of the Key Management Server (KMS) is unavailable, which is not very helpful if you are trying to troubleshoot a KMS issue. 

But now look what happens when you run the same command as Administrator (i.e. with elevated privleges).

Name: Windows Server(R), ServerStandard edition
Description: Windows Operating System - Windows Server(R), VOLUME_KMSCLIENT channel
Partial Product Key: BFGM2
License Status: Licensed
Volume activation expiration: 250200 minute(s) (173 day(s))

Key Management Service client information
    Client Machine ID (CMID): 3af07e3c-b291-47ad-bbf9-cc6278b3c923
    KMS machine name from DNS: kms1.contoso.com:1688
    KMS machine extended PID: 55032-00152-339-003838-03-5129-6001.0000-0062009
    Activation interval: 120 minutes
    Renewal interval: 10080 minutes

In this case the name of the KMS server is shown correctly.

I think it would be more helpful if, in the first example above, the whole command were to fail with an error indicating that elevated privileges are required to successfully complete the command.  The fact that the command partially completes only causes confusion.

Windows Server 2008 User Account Control Gotcha #1

I’ve been working with both Vista and Windows Server 2008 for quite a while now, but I still manage to fall foul of User Account Control, especially when working from the command prompt.  As you will no doubt be aware, there are certain tasks that need elevated privileges and these require you to open the command window as Administrator (you do this by right-clicking the command prompt icon and selecting “Run As Administrator”).

If you try to run tasks that require elevated privilege in a normal (i.e. unprivileged) command window, one of two things will happen.  Either the command that you are attempting to run will tell you that it requires elevated privileges, or it will fail with an (often obscure and unhelpful) error message.  Here’s an example.

The other day I wanted to run the Active Directory Schema MMC snap-in (schmmgmt.msc) on a DC.  To access the snap-in you first need to register a dll named schmmgmt.dll.  The command to do this is:

 regsvr32 schmmgmt.dll

On a Windows Server 2008 machine this activity requires elevated privileges, so you need to run the command as Administrator.  If you don’t, you will see the error below.

The module “schmmgmt.dll” was loaded but the call to DllRegisterServer failed with the error code  0x80040201

uac1.JPG

It took me a good few minutes to work out what I had done wrong. Doh!  Hopefully I’ll eventually get the hang of User Account Control.

Error Events 1136 Following Windows Server 2008 Forestprep

Most people are (quite rightly) terrified of seeing a whole bunch of errors in the DS event log following a schema update.   This happened to me in a lab environment at a customer recently and I thought I would share the information here.

I ran Windows Server 2008 adprep /forestprep on a Windows Server 2003 SP1 DC.  All seemed to go well and the schema update completed successfully.  Before moving on I checked the Directory Service event log and found a large number of 1136 error events.  There were effectively two events that were recurring, as shown below.

Event Type: Error
Event Source: NTDS General
Event Category: DS Schema
Event ID: 1136
Date:  23/01/2009
Time:  1:02:38 p.m.
User:  NT AUTHORITY\ANONYMOUS LOGON
Computer: DC1
Description:
Active Directory failed to create an index for the following attribute.

Attribute identifier:
591789
Attribute name:
msFVE-RecoveryGuid

A schema cache update will occur 5 minutes after the logging of this event and will attempt to create an index for the attribute.

Additional Data
Error value:
-1403 JET_errIndexDuplicate, Index is already defined

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Event Type: Error
Event Source: NTDS General
Event Category: DS Schema
Event ID: 1136
Date:  23/01/2009
Time:  1:01:53 p.m.
User:  NT AUTHORITY\ANONYMOUS LOGON
Computer: DC1
Description:
Active Directory failed to create an index for the following attribute.

Attribute identifier:
591822
Attribute name:
msFVE-VolumeGuid

A schema cache update will occur 5 minutes after the logging of this event and will attempt to create an index for the attribute.

Additional Data
Error value:
-1403 JET_errIndexDuplicate, Index is already defined

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp

Some Googling revealed the problem to be to do with a combination of the BitLocker Drive Encryption schema updates that are included as part of the Windows Server 2008 schema extensions together with certain language locales (New Zealand English in my case).

The resolution of the issue involves removing the CONTAINER_INDEX setting within the searchFlags attribute value of the msFVE-VolumeGuid and msFVE-RecoveryGuid attribute schema objects.  To do this you can use ADSIEdit to modify the value for both attributes from 27 to 25, as shown in the screenshot below.

 ms-fve-recoveryguid.jpg

Once the modifications have been made, the errors no longer recur.

Interestingly, I could not reproduce the problem when running Windows Server 2008 forestprep on a Windows Server 2003 R2 SP2 DC with the same language locale.

For more information see the Microsoft KB article below.

Error messages after you install the BitLocker Drive Encryption schema updates in a Windows Server 2003 domain

PowerShell GPMC scripts

 

The other day I had a need to configure scheduled backups of GPOs to file on a Windows Server 2008 Domain Controller.  Aha (I thought), I’ve done this before using the BackupAllGPOs.wsf script that is included along with a whole bunch of other handy scripts when you install the Group Policy Management Console (GPMC).  After a few minutes of fruitless searching on my Windows Server 2008 DC I realised that although the GPMC was installed (as a feature) the scripts were nowhere to be found.  After some Googling I found out that I hadn’t been singled out for victimisation - unlike Windows Server 2003, the scripts just aren’t installed by default in Windows Server 2008 when you enable the GPMC feature.  I discovered that you could download the Vista and Windows Server 2008 versions of the scripts here:

Group Policy Management Console Sample Scripts

It puzzled me that the scripts weren’t included by default.  I suspect the Vista and WS2008 versions of the scripts were developed after the products had shipped.  Anyway, it made me think that Microsoft maybe wanted me to work with PowerShell and not VBScript.  Aha (I thought again), I’ll see if I can find the PowerShell equivalent of the GPMC scripts.  After a fair bit of searching I found two options.

Option 1.

SDM GPMC PowerShell Cmdlets from Darren Mar-Elia

Option 2.

Sample functions provided by Thorbjörn Sjövold in his Technet Magazine article, Simplify Group Policy Administration with Windows PowerShell

The first option requires installing the Cmdlets from an .msi install package, something I didn’t really want to have to do in the environment I was working with.

The second option proved a winner and provided the functions I needed to get my PowerShell script up and running within a few minutes.  Here’s my script to backup all the GPOs in a given domain. 

## FileName: BackupGPOs.ps1
## Date: 13.12.2008
## Purpose:  Backs up all GPOs within domain to file

## Variables

$backupDirectory = “c:\backup\GPO”
$domainName = [System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain().Name

## Functions

# Source: http://technet.microsoft.com/en-us/magazine/cc162355.aspx

###########################################################################
# Function   : BackupAllGpos
# Description: Backs up all GPOs in a Domain
# Parameters : $backupDirectory - The directory where the backups will be stored
#            : $domainName - The dns name, e.g. microsoft.com, of the domain to operate on
#            : $backupComment - An optional comment for the backups, if nothing is passed the current date will be
used.
# Returns    : N/A
###########################################################################
function BackupAllGpos(
  [string] $backupDirectory=$(throw ‘$backupDirectory is required’),
  [string] $domainName=$(throw ‘$domainName is required’),
  [string] $backupComment=$(get-date))
{
  $gpmAllGposInDomain = GetAllGposInDomain $domainName

  foreach ($gpmGpo in $gpmAllGposInDomain) # Iterate through all the GPOs
  {
    “Back up GPO : ” + $gpmGpo.DisplayName
    $gpmResult = $gpmGpo.Backup($backupDirectory, $backupComment) # Backup the GPO
    [void] $gpmResult.OverallStatus
    $gpoBackup = $gpmResult.Result
  }
}

###########################################################################
# Function   : GetAllGposInDomain
# Description: Returns all GPOs in a domain
# Parameters : $domainName - The dns name, e.g. microsoft.com, of the domain to operate on
# Returns    : All Group Policy Objects in the supplied domain
###########################################################################
function GetAllGposInDomain(
  [string] $domainName=$(throw ‘$domainName is required’))
{
  $gpm = New-Object -ComObject GPMgmt.GPM # Create the GPMC Main object
  $gpmConstants = $gpm.GetConstants() # Load the GPMC constants
  $gpmDomain = $gpm.GetDomain($domainName, “”, $gpmConstants.UseAnyDC) # Connect to the domain passed using any DC
  $gpmSearchCriteria = $gpm.CreateSearchCriteria() # Create a search criteria without any restrictions
  $gpmDomain.SearchGPOs($gpmSearchCriteria) # Search and find all GPOs in the domain, this will return the array
}

## Main

backupAllGpos $backupDirectory $domainName

## End

Note that I’ve set the $domainName variable to match the domain of the computer from which the script is run.  To set the variable to match the domain of the user account under which the script runs change it to (may wrap):

[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().Name

The sample functions provided by Thorbjörn are comprehensive and cover nearly all of the features included in the original GPMC VBScripts.  I encourage you to take a look.

Exporting Events with Wevtutil Using a Time-Based Query

Windows Server 2008 (and Vista) offer improved options for event log management.  For example, you now have the option to forward events to a central event collector server.  You also now have powerful filtering capabilities.  One of the features I like is the Wevtutil command-line tool that allows you to retrieve, query, archive, export and clear events.   It’s the best option you have if you use Server Core and don’t want to open the firewall to allow remote access using the Event Viewer UI.

Recently, I had to schedule the export of events using Wevtutil using a time-based query.  It took me a little while to get the query syntax right, so I thought I would share it with you here.

Let’s take a scenario in which you want to export all events from in the past 24 hours from the security log to a *.evtx file.  (Note. The default format for exported event log files in Vista and Windows Server 2008 is *.evtx.  For a good explanation of the differences between evt and evtx see this blog entry).   You can leverage the Windows Event Viewer (eventvwr) to assist you with obtaining the query required to filter the log to show only events from the past 24 hours.  To do this, click on your event log of choice (in this case Security).  In the right-hand action pane click Filter Current Log.  Within the Filter tab, select the drop-down list next to Logged and choose Last 24 hours.  Now click on the XML tab.   The query is embedded within the XML content, as follows:

 *[System[TimeCreated[timediff(@SystemTime) <= 86400000]]]

xml-query.jpg

The Wevtutil command to use the filter is shown below (may wrap).

wevtutil.exe epl Security C:\SecurityLog24hours.evtx “/q:*[System[TimeCreated[timediff(@SystemTime) <= 86400000]]]” /ow:true

Note that you have to replace the “&lt;” escape sequence meaning “less than” from the XML original with the “<” character, otherwise the query does not work and you will receive the error:

Failed to export log Security. The specified query is invalid.

The time-based filter I have used in this example only scratches the surface of the query capabilities you have with Wevtutil.  The fact that you can leverage the capabilities within the Event Viewer UI to assist with building the queries takes a lot of the pain away.  For more information about Wevtutil, including all the available command line options, see this page on Microsoft Technet.

How to Schedule Active Directory Snapshots in Windows Server 2008

If you’ve played around with Windows Server 2008 Active Directory Domain Services, you will probably be familiar with the snapshot feature within NTDSUTIL.  The feature allows you to take snapshot of the volumes that host the AD components and to then mount the snapshot.  Once mounted, you can use DSAMAIN.EXE to expose a read-only copy of the AD database to your favourite browsing tool (LDP.EXE, ADSIEDIT.MSC, DSA.MSC, ADFIND.EXE, etc.).  The process for doing this is well documented elsewhere, so I don’t intend to reproduce it here. 

 

Microsoft recommends that you schedule regular snapshots, as this provides you with a quick method of checking the contents of the directory at different time slices in the past.  One advantage of this that you can quickly identify which backup to use when needing to authoritatively restore accidentally deleted AD objects from backup.

 

What isn’t quite so well documented it the process to schedule regular snapshots.  It took me a little while to configure this properly, so I thought I would share it with you here.

 

Windows Server 2008 comes with a re-vamped Task Scheduler.  You can configure tasks using both the UI as well as the command line (schtasks.exe).  I prefer to use the command line as it has the advantage of allowing you to set tasks to run under the SYSTEM account.  It is also the only option if you are using Server Core, unless you want to open the firewall to allow remote task scheduling from a computer running the full version.

 

Here’s the command line I use.  Note that this is all on one line (wrapped here to fit page width).

 SCHTASKS /Create /RU SYSTEM /SC DAILY /TN MYTASKS\DS_SNAPSHOT /TR “%windir%\system32\ntdsutil.exe sn \”ac i ntds\” create q q” /ST 05:00 

It is worth pulling the command arguments apart to explain them better

 

/Create - pretty obvious.  It instructs schtasks to create a new task.

/RU SYSTEM - the task will run under the SYSTEM account.  Note that you don’t need to specify a password when using SYSTEM.

/SC DAILY- the task will run daily

/TN MYTASKS\DS_SNAPSHOT - I’ve called the task name DS_SNAPSHOT and this will be created within the MYTASKS task folder.  The folder will be created automatically if it does not already exist.

/TR “%windir%\system32\ntdsutil.exe sn \”ac i ntds\” create q q” - This is the task action.  It runs NTDSUTIL with arguments.  Note that the double quotation marks within the arguments have to be escaped with the backslash character

/ST 05:00 - the start time for the task will be 5am.

 

The command line shown above assumes that you are working on the local machine on which you want to create the task.  If defining the task for a remote computer, use the additional command line options shown below.

 SCHTASKS /Create /S MYSERVER /U administrator /P xxxxx /RU SYSTEM /SC DAILY /TN MYTASKS\DS_SNAPSHOT /TR “%windir%\system32\ntdsutil.exe sn \”ac i ntds\” create q q” /ST 05:00 

Once you’ve run the command you can verify the settings in the Task Scheduler UI.

 

If you’re feeling brave you can also have a look at scripting the task creation, as described here.

 

Should all my DCs run on Server Core?

 

Last week I initiated a discussion on the ActiveDir.org mailing list about running Windows Server 2008 Domain Controllers on Server Core.  I was curious to see whether there were any good reasons why all DCs (RODCs and RWDCs) should not be run on Server Core as a best practice.   The conclusion reached was that, with the possible exception of smaller organisations, the benefits of Server Core far outweigh any limitations.

Why Server Core is a good thing

  • Because it installs only a subset of the full operating system, Server Core provides a smaller surface area for potential security compromise.
  • Server Core requires fewer patches, thereby reducing both the administrative overhead and the potential risk of instability.
  • Server Core has a lower system resource overhead, delivering a better bang-for-buck for your server hardware investment.
  • Because of it’s small footprint, Server Core lends itself to virtualisation, again delivering a better return on your hardware investment.

Server Core sounds perfect, so why isn’t everyone using it?

  • There is no UI, which means that administrators unfamiliar with the command line have to get to grips with new ways of doing things.  Having said that, you still have the option to run all of the AD admin tools remotely by running RSAT on a machine running VISTA or the full UI version of Windows Server 2008.
  • DC promotion becomes a little more long-winded as it requires you to create an answer file and run DCPROMO in unattended mode.
  • The .NET Framework (and hence Powershell) is not supported, which means you cannot run code locally that requires the Framework.  There are however a number of workarounds to this and changes coming in Powershell 2.0 improve the options for running cmdlets against remote computers.

Despite the minor inconveniences for administrators I would recommend using Server Core for all your Windows Server 2008 Domain Controllers.  For me benefits are too compelling not to.   I predict that as more Windows Server 2008 forests are deployed, Domain Controllers on Server Core will start to be considered best practice.  I also believe that Server Core will become the primary Windows Server platform within the next 10 years, with the full UI version either vanishing altogether or becoming marginalised for use only in small organisations. 

But then I chose Betamax over VHS, so what do I know. :-)

LDP.EXE Improvements in Windows Server 2008

 

Next to ADFIND.EXE, LDP is the tool I probably use most often when working with Active Directory.  It’s an LDAP client that was originally developed for use purely within Microsoft. It can be used for browsing, searching and making changes via the LDAP protocol.  Because of its usefulness, Microsoft included LDP in the Support Tools in Windows 2000 and Windows Server 2003.  It has now gone mainstream and is included as part of the Windows Server 2008 installation. 

Here are some of the improvements I have become aware of in the Windows Server 2008 version of LDP.  Note that with the exception of the help documentation, these improvements were first introduced in the versions of LDP that shipped with ADAM in Windows Server 2003 R2 and with the ADAM SP1 download.

Bind as currently logged on user

The long-winded method of getting going with LDP is to Connect and Bind using those options from the Connection menu and fill in all the boxes.  With the Windows Server 2000 and 2003 versions of LDP if you simply want to connect and bind to a DC in the domain that you are already logged into then you don’t need to both with all that.  You simply select Bind from the Connection menu, leave all the boxes empty and then select OK, as shown below.

Bind Windows Server 2003

That’s it - you are then bound to an in-site DC using your current credentials.  There is no need to use the Connect option, unless you need to target a specific DC or port number.

Windows Server 2008 makes this “bind as currently logged on user ” option explicit by a modification to the Bind dialogue options, as shown below.

Bind as currently logged on user

The behaviour is otherwise the same as the Bind method in earlier versions of LDP.

SID Lookup

With LDP you can lookup an object in the directory based on its security identifier (also known as the objectSid attribute).  The method for doing this is convoluted and involves specifying the SID value as the search base using a special syntax in the form <SID=<objectSid>>, e.g. <SID=S-1-5-21-2596592837-3109173549-302247358-1116>.  For this to work the search scope needs to be set to Base, as shown below.

SID Lookup Windows Server 2003

Windows Server 2008 makes the whole process of SID lookup much easier.  You can still use the method shown above, but there is now also a separate SID Lookup option within the Utilities menu.  This is much quicker if you simply need to resolve the SID to the friendly name.  The screenshot below shows the new feature.

SID Lookup Windows Server 2008

ACL Editor

The version of LDP included with Windows Server 2008 delivers the ability to edit object security descriptors (see screenshot below).  Previous versions of LDP allowed you to view but not edit DACLs and SACLs.

acl editor

Help Documentation

In earlier versions of LDP help comes in the form of a 13.3MB file by the name of LDP.DOC.  While the information in the file is comprehensive and useful, very few people knew of its existence.  The documentation for the Windows Server 2008 version of LDP is now fully integrated into Windows Help and Support.

 

There may well be other improvements within the utility that I am not aware of.  If you’re not already familiar with LDP I recommend you take the time get to know it.  It seems that Microsoft is committed to maintaining the tool and extending its capabilities.

Mixed bag ‘o Nuts

 

It’s been a little while since I’ve blogged, so here’s a more or less random collection of snippets for you to enjoy/delete at leisure.

Quest acquires Netpro

Wow, this one took me by surprise, especially as I have been contracting to Quest on and off for the past 10 months.  Two of the biggest names in the Active Directory management space are now one.  It’s going to take quite a while for competitors to breach the gap.

Microsoft acquires Deano

I just learned from Joe Richard’s blog that Dean Wells has taken a position at Microsoft within the Directory Services product team in Redmond.  I’ve known Dean for the past six years or so and he is one of the most knowledgeable AD people around.  He’s forgotten more about AD than most of us know.  I’m sure he’ll be a huge asset to the DS team.  Good luck Deano!

Handy CSV import script

I came across a good vbscript for modifying AD attribute values using a CSV input file.  There are a number of methods and scripts around that can work with CSV input files, but the cool thing about this script is that can easily be modified to accommodate different attributes.  Check it out here.  I’m thinking of putting together a Powershell version of the same thing.

Good anecdote from Don Hacherl

A while back I blogged about one of the new features of AD in Windows Server 2008: protection from accidental deletion.  If you were looking for a good supporting anecdote to hasten the deployment of this feature in your environment, look no further than this nugget from one of the Godfathers of AD, Don Hacherl, posted on the mailing list at ActiveDir.org:

From: ActiveDir-owner@mail.activedir.org [mailto:ActiveDir-owner@mail.activedir.org] On Behalf Of Don Hacherl
Sent: Sunday, 7 September 2008 4:52 p.m.
To: ActiveDir@mail.activedir.org
Subject: RE: [ActiveDir] Delegating Start/Stop Service on DCs

Years ago I worked with a “domain admin qualified” person at Microsoft who fat fingered the admin UI and deleted a container instead of the object he was intending.  The container was named “North America”, and that was the night we wrote our first authoritative restore tool.  (Later he said “I wondered why it was taking so long to finish.”)

A tightly constrained proxy program can be more reliable and less dangerous than a distracted human administrator.

Don

Tech-Ed

My sessions at Auckland and Sydney completed without mishap and my demos (bizarrely) worked without one single blue-screen :-)  The feedback was positive and I was happy with the eval scores.  Looking at the video of my session, I realise that I need to slow down a little, engage the audience more and stop saying “um” so much.  Talking in front of a large audience is nerve-wracking and I wasn’t even aware I was doing it.

Tech-Ed in Sydney was also a good opportunity to catch up with fellow DS MVP Gil Kirkpatrick and my ex-colleagues from Gen-i, Craig Pringle and James Brombergs.

Hyper-v logoff / logon issue

When running through final preparations for a presentation to a few hundred people (well, tens of people…ok, at least 5 people…proabably) the last thing you need is for your Hyper-v environment to start misbehaving.   This is exactly what happened to me and I’ve just found the cause, so am feeling a lot more relaxed about things.

 I had prepared a number of Hyper-v VMs (child partitions, if using the Microsoft jargon) and found I was not able to log on to any of them following a log off.  The VMs were a mix of Windows Server 20008 64bit and 32bit.   When trying to re-log on, I received the error “Your system is running low on resources.  You cannot log on as a new user.  Please use an account that has already been logged on.”

The only workaround I found for this scenario was to shut down the machine and boot up again. 

After investigation the error about “running low on resources” appeared to be spurious.  The VMs were running fine and weren’t under any real resource load.  Assigning more memory and/or additional processors made no difference.  The problem was 100% reproducible.

 In the end I noticed that a newly created Windows Server 2008 VM did not exhibit the same problem.  From there it was a question of trial and error, running through each step of my build process to see what introduced the problem.  Bizarrely, it turned to be changing the default 96 DPI font size to large font (120 DPI).  I had been changing to the bigger font to save my failing eyesight! 

 As soon as I changed the font back to 96 DPI on my VMs the problem disappeared.

 I’m now trying to find out whether this is a bug, or just something weird in my environment.

« Previous PageNext Page »