Managing DFS namespaces from the command line
Last year, I posted about the DFS Modlink utility which you need if you want to manipulate DFS link states against DFS-N – Windows 2003 didn’t have any non-GUI tooling to do that, except for the Win32_DFSnode WMI properties.
Windows XP however does not support that particular interface, which leaves only modlink as a way to disable or enable a DFS link.
From Windows 2008 onward, that sorely missing functionality is available in the revamped dfsutil commandline tool. And as an added bonus, changing the TTL for a link is also possible.
Even more, dfsutil in 2008R2 (and therefore Windows 7 clients with RSAT installed) lets you set the Access Based Enumeration property.
Below are the property commands:
1: E:\>dfsutil property 2: 3: DESCRIPTION: 4: Displays or modifies the properties of a folder target (link target) or 5: namespace server (root target). 6: 7: ------ PROPERTY Commands Supported ------ 8: 9: Sitecosting Displays or modifies site costing for a namespace.
10: RootScalability Displays or modifies the namsespace polling mode. 11: ABE Enable/Disable/View ABE property of a namespace.12: Insite Displays or modifies the in-site property.
13: TargetfailBack Displays or modifies client fail back. 14: SD Set/Get Security Information on the folder. 15: State Displays or modifies a folder target or namespace server. 16: TTL Displays or changes client referral caching. 17: PriorityRank Displays or changes the ordering method (priority rank). 18: PriorityClass Displays or changes the target priority.19: Comment Sets or displays the comment for a namespace or link.
So, what do we do with this? Let’s say you’re migrating your DFS-Namespace enabled* Datashares to a newer fileserver with more storage capacity.
*no DFS-R , in case you’re wondering, because the original server might be a Windows 2003 non-R2 install.
A default link timeout is 7200 seconds or 2×60x 60 seconds = 2 hours, meaning your DFS client will check for changes in state after that time. During your migration window, you’ll want to ensure that any changes are picked up within a shorter time.
1: E:\>dfsutil property ttl \\alt-92.net\data\share1
2: The timeout for \\alt-92.net\data\share1 is 7200
First, we’ll change the timeout setting to a 5 minute setting:
1: E:\>dfsutil property ttl set \\alt-92.net\data\share1 300
2: 3: Done processing this command. 4: 5: E:\>dfsutil property ttl \\alt-92.net\data\share1
6: The timeout for \\alt-92.net\data\share1 is 300
Then, using both dfscmd and dfsutil, we’ll add our new fileshare to the link AND set it offline:
1: dfscmd /add \\alt-92.net\data\share1 \\newserver\data\share1
2: dfsutil property state offline \\alt-92.net\data\share1 \\newserver\data\share1
After syncing the content with robocopy (be sure to check the /MT switch for multithreading on Windows 2008R2 or Windows 7) we now flip the link state on both shares and restore the timeout value to its former setting:
1: dfsutil property state offline \\alt-92.net\data\share1 \\oldserver\data\share1 2: dfsutil property state online \\alt-92.net\data\share1 \\newserver\data\share1 3: dfsutil property ttl set \\alt-92.net\data\share1 7200After that, we’ll decommission the old fileserver, by taking the shares offline and removing the old links from the DFS Namespace with dfscmd:
1: dfscmd /remove \\alt-92.net\data\share1 \\oldserver\data\share1Et voila: we’ve migrated our DFS enabled fileshares to a new server with minimal downtime.
Fully scripted, its now feasible to migrate a DFS Namespace root with hundreds of links in just a few hours (including the final replication with robocopy – the bulk copy we’ve started a couple of days in advance) .
- Comments Comments Off
VMware adapters & unidentified networks in Vista & 7
Most VMware Workstation users prefer not to enable the Host Only and NAT adapters, but for some scenarios you want to be able to do so.
Unfortunately, as soon as you enable those adapters, they’re detected as unidentified networks (worst-case) or as a separate public/private network connection in the Network and Sharing Center.

And as soon as that happens, Windows (Advanced) Firewall kicks into Public mode effectively locking your box down. Which is A Good Thing – mostly, just not always what you want.
VMware KB article 1004813 also describes possible solutions to fix this. Aside from disabling the NICs (hey, we wanted to use those, remember?) or changing the NICs over to Private Network (which you would have to do every reboot), you can configure the VMware adapters as so called Endpoint Devices per the procedure listed.
More information on the Endpoint device configuration is available on MSDN:
http://msdn.microsoft.com/en-us/library/bb201634.aspx
Reverting to the normal behaviour is as easy as flipping the DWORD to 0 or deleting the entry.
There is also a useful side effect to the *NdisDeviceType setting:
Remote Desktop connections will keep working even with enabled virtual NICs, whereas by default Remote Desktop (TS) binds itself to all available network connections.
Which means I can finally RD into my desktop machine from my laptop with Host-Only and NAT adapters enabled to run a proper multi-machine, multi-network test.
Yay
[edit]
Link to KB article fixed
- Comments Comments Off
Detecting and installing WSUS updates in Server 2008 Core
On a normal GUI-box, detecting or installing new updates after a fresh install is reasonably easy.
You just click the Updates Control panel item, or, for the more commandline orientated folks, run a wuauclt /detectnow and wait for the “There are new updates available” Systray icon to appear.
The problem with Server Core … there’s no way for you to see the “updates to install” notice in the system tray when you log on to the computer because, well, there’s no systray!
In comes a handy piece of VBscript that allows you to do a manual quick check and start off the installation process, using the in-box Windows Update Agent API.
http://msdn.microsoft.com/en-us/library/aa387102(VS.85).aspx
Although the MSDN article states it does not run against SUS 1.0 servers, you don’t have to worry because both Windows Update (site) and WSUS 3.x employ the WUA API.
Save and run the script in the command prompt as “cscript
01 02 Set updateSession = CreateObject("Microsoft.Update.Session")03 Set updateSearcher = updateSession.CreateupdateSearcher()04 05 WScript.Echo "Searching for updates..." & vbCRLF06 07 Set searchResult = _08 updateSearcher.Search("IsInstalled=0 and Type='Software'")09 10 WScript.Echo "List of applicable items on the machine:"11 12 For I = 0 To searchResult.Updates.Count-113 Set update = searchResult.Updates.Item(I)14 WScript.Echo I + 1 & "> " & update.Title15 Next16 17 If searchResult.Updates.Count = 0 Then18 WScript.Echo "There are no applicable updates."19 WScript.Quit20 End If21 22 WScript.Echo vbCRLF & "Creating collection of updates to download:"23 24 Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")25 26 For I = 0 to searchResult.Updates.Count-127 Set update = searchResult.Updates.Item(I)28 WScript.Echo I + 1 & "> adding: " & update.Title29 updatesToDownload.Add(update)30 Next31 32 WScript.Echo vbCRLF & "Downloading updates..."33 34 Set downloader = updateSession.CreateUpdateDownloader()35 downloader.Updates = updatesToDownload36 downloader.Download()37 38 WScript.Echo vbCRLF & "List of downloaded updates:"39 40 For I = 0 To searchResult.Updates.Count-141 Set update = searchResult.Updates.Item(I)42 If update.IsDownloaded Then43 WScript.Echo I + 1 & "> " & update.Title44 End If45 Next46 47 Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")48 49 WScript.Echo vbCRLF & _50 "Creating collection of downloaded updates to install:"51 52 For I = 0 To searchResult.Updates.Count-153 set update = searchResult.Updates.Item(I)54 If update.IsDownloaded = true Then55 WScript.Echo I + 1 & "> adding: " & update.Title56 updatesToInstall.Add(update)57 End If58 Next59 60 WScript.Echo vbCRLF & "Would you like to install updates now? (Y/N)"61 strInput = WScript.StdIn.Readline62 WScript.Echo63 64 If (strInput = "N" or strInput = "n") Then65 WScript.Quit66 ElseIf (strInput = "Y" or strInput = "y") Then67 WScript.Echo "Installing updates..."68 Set installer = updateSession.CreateUpdateInstaller()69 installer.Updates = updatesToInstall70 Set installationResult = installer.Install()71 72 'Output results of install73 WScript.Echo "Installation Result: " & _74 installationResult.ResultCode75 WScript.Echo "Reboot Required: " & _76 installationResult.RebootRequired & vbCRLF77 WScript.Echo "Listing of updates installed " & _78 "and individual installation results:"79 80 For I = 0 to updatesToInstall.Count - 181 WScript.Echo I + 1 & "> " & _82 updatesToInstall.Item(i).Title & _83 ": " & installationResult.GetUpdateResult(i).ResultCode84 Next85 End If
- Comments Comments Off