forked from mardahl/PSBucket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Convert-DFSn2FQDN
75 lines (50 loc) · 2.36 KB
/
Convert-DFSn2FQDN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<#
.SYNOPSIS
Quick and dirty script to aid in converting a domain based DFS Namespace to FQDN as stated here:
https://support.microsoft.com/en-us/help/244380/how-to-configure-dfs-to-use-fully-qualified-domain-names-in-referrals
.EXAMPLE
Run it from an adminsitrative PowerShell ISE session on each DFS Namespace member.
.NOTES
Please remmeber to do a backup of all META data before using this script, and read the article!
I take no responsability for anything you do with this script.
Author: Michael Mardahl
Twitter: @michael_mardahl
Blog: msendpointmgr.com
License: MIT - leave author info
#>
#Requires -RunAsAdministrator
$dfsrootFQDN = "contoso.local" #must be the root of the path you access DFS via.
$dfsnode = $env:COMPUTERNAME
#getting list of target namespaces
$targets = Get-DfsnRoot | Select-Object Path -ExpandProperty Path
#removing namespaces from members server that the script is being run on
foreach ($path in $targets) {
$pathfix = $path -replace "$dfsrootFQDN","$dfsnode"
Remove-DfsnRootTarget -TargetPath $pathfix
}
Start-Sleep -Seconds 15
#Enabling FQDN on the member server
Set-DfsnServerConfiguration –ComputerName $dfsnode –UseFqdn $true
Start-Sleep -Seconds 15
#restarting services
Stop-Service dfs; Start-Service dfs
Start-Sleep -Seconds 15
#Re-adding namespaces from active directory
foreach ($path in $targets) {
$pathfix = $path -replace "koncern.local","$dfsnode"
Dfsutil target add $pathfix
}
#### TOOLS SECTION for advanced users
<# run individually - DO NOT JUST EXECUTE ALL THIS CODE!
#BACKUP NAMESPACE METADATA TO FILE - test and adjust the array index of $name if needed.
$targets = Get-DfsnRoot | Select-Object Path -ExpandProperty Path
foreach ($path in $targets) {
$name = $path -split "\\"
$destination = "c:\$($name[3])-dfsBAK.txt"
dfsutil.exe root export $path > $destination
}
# manual import (make sure you replaced all netbios values in the export with FQDN values)
dfsutil.exe root import set c:\namespace-dfsBAK.txt \\contoso.local\DFSNamespace
# Cleanup of broken Namespace, if you had an accident and need to rebuild it, then cleanup with this and manually re-create the namespace - then wait for replication - the import from backup with the above command.
Remove-DfsnRootTarget -TargetPath \\namesapceMember.contoso.local\DFSNamespace -Path \\contoso.local\DFSNamespace -Cleanup
#>