Skip to content

Instantly share code, notes, and snippets.

@andre-brongniart
Created February 18, 2016 01:17
Show Gist options
  • Save andre-brongniart/d3db19d61da3cc41e5bf to your computer and use it in GitHub Desktop.
Save andre-brongniart/d3db19d61da3cc41e5bf to your computer and use it in GitHub Desktop.
PS C:\Windows\system32> $NewFolderA = 'rob'
$NewFolderB = 'andre'
$NewFolderC = 'gerhard'
$servers = (‘i5-r-dfs-001’,’i5-r-dfs-002’)
$dfsroot = (‘C:\dfsroots\filestore’)
$foldershare = (‘C:\dfsroots\filestore’,’C:\shares\rob’,’C:\shares\andre’,’C:\shares\gerhard’)
foreach ($server in $servers) {New-Item "\\$server\c$\shares\$NewFolderA" -ItemType Dir}
foreach ($server in $servers) {New-Item "\\$server\c$\shares\$NewFolderB" -ItemType Dir}
foreach ($server in $servers) {New-Item "\\$server\c$\shares\$NewFolderC" -ItemType Dir}
foreach ($server in $servers) {New-Item "\\$server\c$\dfsroots\filestore" -ItemType Dir}
foreach ($server in $servers) {Install-WindowsFeature FS-DFS-Namespace,FS-DFS-Replication –IncludeManagementTools –ComputerName $server}
$foldershare | ForEach-Object {$sharename = (Get-Item $_).name; New-SMBShare -Name $shareName -Path $_ -FullAccess Everyone}
New-DfsnRoot -TargetPath "\\i5-r-dfs-001\filestore" -Type DomainV2 -Path "\\uk02.kexpress.net\filestore" -TargetState Online
$foldershare | Where-Object {$_ -like "*shares*"} | ForEach-Object {$name = (Get-Item $_).name; $DfsPath = (‘\\uk02.kexpress.net\filestore\’ + $name); $targetPath = (‘\\i5-r-dfs-001\’ + $name);New-DfsnFolderTarget -Path $dfsPath -TargetPath $targetPath}
New-DfsReplicationGroup -GroupName I5-DFS-RG01 | New-DfsReplicatedFolder -FolderName rob,andre,gerhard | Add-DfsrMember -ComputerName $servers
Add-DfsrConnection -GroupName I5-DFS-RG01 -SourceComputerName i5-r-dfs-001 -DestinationComputerName i5-r-dfs-002
Set-DfsrMembership -GroupName I5-DFS-RG01 -FolderName rob -ComputerName i5-r-dfs-001 -ContentPath ’C:\shares\rob’ –PrimaryMember $true -Force
Set-DfsrMembership -GroupName I5-DFS-RG01 -FolderName rob -ComputerName i5-r-dfs-002 -ContentPath ’C:\shares\rob’ -Force
Set-DfsrMembership -GroupName I5-DFS-RG01 -FolderName andre -ComputerName i5-r-dfs-001 -ContentPath ’C:\shares\andre' –PrimaryMember $true -Force
Set-DfsrMembership -GroupName I5-DFS-RG01 -FolderName andre -ComputerName i5-r-dfs-002 -ContentPath ’C:\shares\andre' –Force
Set-DfsrMembership -GroupName I5-DFS-RG01 -FolderName gerhard -ComputerName i5-r-dfs-001 -ContentPath ’C:\shares\gerhard' –PrimaryMember $true -Force
Set-DfsrMembership -GroupName I5-DFS-RG01 -FolderName gerhard -ComputerName i5-r-dfs-002 -ContentPath ’C:\shares\gerhard' –Force
Directory: \\i5-r-dfs-001\c$\shares
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18/02/2016 01:13 rob
Directory: \\i5-r-dfs-002\c$\shares
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18/02/2016 01:13 rob
Directory: \\i5-r-dfs-001\c$\shares
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18/02/2016 01:13 andre
Directory: \\i5-r-dfs-002\c$\shares
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18/02/2016 01:13 andre
Directory: \\i5-r-dfs-001\c$\shares
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18/02/2016 01:13 gerhard
Directory: \\i5-r-dfs-002\c$\shares
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18/02/2016 01:13 gerhard
New-Item : An item with the specified name \\i5-r-dfs-001\c$\dfsroots\filestore already exists.
At line:10 char:32
+ foreach ($server in $servers) {New-Item "\\$server\c$\dfsroots\filestore" -ItemT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (\\i5-r-dfs-001\c$\dfsroots\filestore:String) [New-Item], IOEx
ception
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
New-Item : An item with the specified name \\i5-r-dfs-002\c$\dfsroots\filestore already exists.
At line:10 char:32
+ foreach ($server in $servers) {New-Item "\\$server\c$\dfsroots\filestore" -ItemT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (\\i5-r-dfs-002\c$\dfsroots\filestore:String) [New-Item], IOEx
ception
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
Success : True
RestartNeeded : No
FeatureResult : {}
ExitCode : NoChangeNeeded
Success : True
RestartNeeded : No
FeatureResult : {}
ExitCode : NoChangeNeeded
New-SMBShare : The name has already been shared.
At line:13 char:65
+ $foldershare | ForEach-Object {$sharename = (Get-Item $_).name; New-SMBShare -Na ...
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_SMBShare:ROOT/Microsoft/Windows/SMB/MSFT_SMBShare) [New-Sm
bShare], CimException
+ FullyQualifiedErrorId : Windows System Error 2118,New-SmbShare
AvailabilityType : NonClustered
CachingMode : Manual
CATimeout : 0
ConcurrentUserLimit : 0
ContinuouslyAvailable : False
CurrentUsers : 0
Description :
EncryptData : False
FolderEnumerationMode : Unrestricted
Name : rob
Path : C:\shares\rob
Scoped : False
ScopeName : *
SecurityDescriptor : O:SYG:SYD:(A;;FA;;;WD)
ShadowCopy : False
ShareState : Online
ShareType : FileSystemDirectory
SmbInstance : Default
Special : False
Temporary : False
Volume : \\?\Volume{e46f3f97-c530-11e5-80bd-806e6f6e6963}\
PSComputerName :
PresetPathAcl : System.Security.AccessControl.DirectorySecurity
AvailabilityType : NonClustered
CachingMode : Manual
CATimeout : 0
ConcurrentUserLimit : 0
ContinuouslyAvailable : False
CurrentUsers : 0
Description :
EncryptData : False
FolderEnumerationMode : Unrestricted
Name : andre
Path : C:\shares\andre
Scoped : False
ScopeName : *
SecurityDescriptor : O:SYG:SYD:(A;;FA;;;WD)
ShadowCopy : False
ShareState : Online
ShareType : FileSystemDirectory
SmbInstance : Default
Special : False
Temporary : False
Volume : \\?\Volume{e46f3f97-c530-11e5-80bd-806e6f6e6963}\
PSComputerName :
PresetPathAcl : System.Security.AccessControl.DirectorySecurity
AvailabilityType : NonClustered
CachingMode : Manual
CATimeout : 0
ConcurrentUserLimit : 0
ContinuouslyAvailable : False
CurrentUsers : 0
Description :
EncryptData : False
FolderEnumerationMode : Unrestricted
Name : gerhard
Path : C:\shares\gerhard
Scoped : False
ScopeName : *
SecurityDescriptor : O:SYG:SYD:(A;;FA;;;WD)
ShadowCopy : False
ShareState : Online
ShareType : FileSystemDirectory
SmbInstance : Default
Special : False
Temporary : False
Volume : \\?\Volume{e46f3f97-c530-11e5-80bd-806e6f6e6963}\
PSComputerName :
PresetPathAcl : System.Security.AccessControl.DirectorySecurity
Description :
Flags :
NamespacePath : \\uk02.kexpress.net\filestore
State : Online
TimeToLive : 300
GrantAdminAccess : {KEXPRESS\Enterprise Admins, UK02kexpress\Domain Admins, NT AUTHORITY\SYSTEM,
KEXPRESS\Enterprise Admins}
Type : Domain V2
PSComputerName :
Path : \\uk02.kexpress.net\filestore
TimeToLiveSec : 300
NamespacePath : \\uk02.kexpress.net\filestore\rob
ReferralPriorityClass : sitecost-normal
ReferralPriorityRank : 0
State : Online
TargetPath : \\i5-r-dfs-001\rob
PSComputerName :
Path : \\uk02.kexpress.net\filestore\rob
NamespacePath : \\uk02.kexpress.net\filestore\andre
ReferralPriorityClass : sitecost-normal
ReferralPriorityRank : 0
State : Online
TargetPath : \\i5-r-dfs-001\andre
PSComputerName :
Path : \\uk02.kexpress.net\filestore\andre
NamespacePath : \\uk02.kexpress.net\filestore\gerhard
ReferralPriorityClass : sitecost-normal
ReferralPriorityRank : 0
State : Online
TargetPath : \\i5-r-dfs-001\gerhard
PSComputerName :
Path : \\uk02.kexpress.net\filestore\gerhard
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-001
DomainName : kexpress.net
Identifier : eb9b50f6-d3b5-4068-94d2-1e2997da2374
Description :
DnsName : i5-r-dfs-001.uk02.kexpress.net
Site : I5
NumberOfConnections : 0
NumberOfInboundConnections : 0
NumberOfOutboundConnections : 0
NumberOfInterSiteConnections : 0
NumberOfIntraSiteConnections : 0
IsClusterNode : False
State : Normal
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-002
DomainName : kexpress.net
Identifier : ab0381d9-c4fe-4431-aa00-569eb9ec291e
Description :
DnsName : i5-r-dfs-002.uk02.kexpress.net
Site : I5
NumberOfConnections : 0
NumberOfInboundConnections : 0
NumberOfOutboundConnections : 0
NumberOfInterSiteConnections : 0
NumberOfIntraSiteConnections : 0
IsClusterNode : False
State : Normal
Add-DfsrMember : A computer with the specified name already exists and cannot be added.
At line:16 char:106
+ ... ndre,gerhard | Add-DfsrMember -ComputerName $servers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (i5-r-dfs-001:String) [Add-DfsrMember], DfsrException
+ FullyQualifiedErrorId : DfsrCore.AddNewMember.MemberAlreadyExists,Microsoft.DistributedFileSystemRepli
cation.Commands.AddDfsrMemberCommand
Add-DfsrMember : A computer with the specified name already exists and cannot be added.
At line:16 char:106
+ ... ndre,gerhard | Add-DfsrMember -ComputerName $servers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (i5-r-dfs-002:String) [Add-DfsrMember], DfsrException
+ FullyQualifiedErrorId : DfsrCore.AddNewMember.MemberAlreadyExists,Microsoft.DistributedFileSystemRepli
cation.Commands.AddDfsrMemberCommand
Add-DfsrMember : A computer with the specified name already exists and cannot be added.
At line:16 char:106
+ ... ndre,gerhard | Add-DfsrMember -ComputerName $servers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (i5-r-dfs-001:String) [Add-DfsrMember], DfsrException
+ FullyQualifiedErrorId : DfsrCore.AddNewMember.MemberAlreadyExists,Microsoft.DistributedFileSystemRepli
cation.Commands.AddDfsrMemberCommand
Add-DfsrMember : A computer with the specified name already exists and cannot be added.
At line:16 char:106
+ ... ndre,gerhard | Add-DfsrMember -ComputerName $servers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (i5-r-dfs-002:String) [Add-DfsrMember], DfsrException
+ FullyQualifiedErrorId : DfsrCore.AddNewMember.MemberAlreadyExists,Microsoft.DistributedFileSystemRepli
cation.Commands.AddDfsrMemberCommand
GroupName : I5-DFS-RG01
SourceComputerName : I5-R-DFS-001
DestinationComputerName : I5-R-DFS-002
DomainName : kexpress.net
Identifier : a25d75c6-9fc9-4f55-b1c6-94518b4274bd
Enabled : True
RdcEnabled : True
CrossFileRdcEnabled : True
Description :
MinimumRDCFileSizeInKB : 64
State : Normal
GroupName : I5-DFS-RG01
SourceComputerName : I5-R-DFS-002
DestinationComputerName : I5-R-DFS-001
DomainName : kexpress.net
Identifier : 5b46113a-ceac-48ac-a606-d37c9ed94aa0
Enabled : True
RdcEnabled : True
CrossFileRdcEnabled : True
Description :
MinimumRDCFileSizeInKB : 64
State : Normal
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-001
FolderName : rob
GroupDomainName : kexpress.net
ComputerDomainName : uk02.kexpress.net
Identifier : eae5af95-6f30-472b-94f9-8e50c7f95a3f
DistinguishedName : CN=dc82fd3d-c0b2-427f-ae29-81af0121801e,CN=5db2620d-df63-47d3-89bd-59517185fb13
,CN=DFSR-LocalSettings,CN=I5-R-DFS-001,CN=Computers,DC=uk02,DC=kexpress,DC=net
ContentPath : C:\shares\rob
PrimaryMember : True
StagingPath : C:\shares\rob\DfsrPrivate\Staging
StagingPathQuotaInMB : 4096
MinimumFileStagingSize : Size256KB
ConflictAndDeletedPath : C:\shares\rob\DfsrPrivate\ConflictAndDeleted
ConflictAndDeletedQuotaInMB : 4096
ReadOnly : False
RemoveDeletedFiles : False
Enabled : True
DfsnPath :
State : Normal
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-002
FolderName : rob
GroupDomainName : kexpress.net
ComputerDomainName : uk02.kexpress.net
Identifier : c36059a4-9e85-4302-8f89-ea38b4cf9222
DistinguishedName : CN=dc82fd3d-c0b2-427f-ae29-81af0121801e,CN=c696bece-31e6-4823-8a5c-67028d4a2380
,CN=DFSR-LocalSettings,CN=I5-R-DFS-002,CN=Computers,DC=uk02,DC=kexpress,DC=net
ContentPath : C:\shares\rob
PrimaryMember : False
StagingPath : C:\shares\rob\DfsrPrivate\Staging
StagingPathQuotaInMB : 4096
MinimumFileStagingSize : Size256KB
ConflictAndDeletedPath : C:\shares\rob\DfsrPrivate\ConflictAndDeleted
ConflictAndDeletedQuotaInMB : 4096
ReadOnly : False
RemoveDeletedFiles : False
Enabled : True
DfsnPath :
State : Normal
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-001
FolderName : andre
GroupDomainName : kexpress.net
ComputerDomainName : uk02.kexpress.net
Identifier : b03a9abd-232a-43fd-a952-9aa9d9c4515f
DistinguishedName : CN=ecbacac9-3603-497a-9374-b503be5fcac0,CN=5db2620d-df63-47d3-89bd-59517185fb13
,CN=DFSR-LocalSettings,CN=I5-R-DFS-001,CN=Computers,DC=uk02,DC=kexpress,DC=net
ContentPath : C:\shares\andre
PrimaryMember : True
StagingPath : C:\shares\andre\DfsrPrivate\Staging
StagingPathQuotaInMB : 4096
MinimumFileStagingSize : Size256KB
ConflictAndDeletedPath : C:\shares\andre\DfsrPrivate\ConflictAndDeleted
ConflictAndDeletedQuotaInMB : 4096
ReadOnly : False
RemoveDeletedFiles : False
Enabled : True
DfsnPath :
State : Normal
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-002
FolderName : andre
GroupDomainName : kexpress.net
ComputerDomainName : uk02.kexpress.net
Identifier : 4d6cca54-a50f-4bd0-9179-d13f125fe1a0
DistinguishedName : CN=ecbacac9-3603-497a-9374-b503be5fcac0,CN=c696bece-31e6-4823-8a5c-67028d4a2380
,CN=DFSR-LocalSettings,CN=I5-R-DFS-002,CN=Computers,DC=uk02,DC=kexpress,DC=net
ContentPath : C:\shares\andre
PrimaryMember : False
StagingPath : C:\shares\andre\DfsrPrivate\Staging
StagingPathQuotaInMB : 4096
MinimumFileStagingSize : Size256KB
ConflictAndDeletedPath : C:\shares\andre\DfsrPrivate\ConflictAndDeleted
ConflictAndDeletedQuotaInMB : 4096
ReadOnly : False
RemoveDeletedFiles : False
Enabled : True
DfsnPath :
State : Normal
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-001
FolderName : gerhard
GroupDomainName : kexpress.net
ComputerDomainName : uk02.kexpress.net
Identifier : 6b29799c-6de3-4d23-8cbe-be7f2679a7b8
DistinguishedName : CN=d237c662-e6ea-40ae-9db9-33e0b28438e2,CN=5db2620d-df63-47d3-89bd-59517185fb13
,CN=DFSR-LocalSettings,CN=I5-R-DFS-001,CN=Computers,DC=uk02,DC=kexpress,DC=net
ContentPath : C:\shares\gerhard
PrimaryMember : True
StagingPath : C:\shares\gerhard\DfsrPrivate\Staging
StagingPathQuotaInMB : 4096
MinimumFileStagingSize : Size256KB
ConflictAndDeletedPath : C:\shares\gerhard\DfsrPrivate\ConflictAndDeleted
ConflictAndDeletedQuotaInMB : 4096
ReadOnly : False
RemoveDeletedFiles : False
Enabled : True
DfsnPath :
State : Normal
GroupName : I5-DFS-RG01
ComputerName : I5-R-DFS-002
FolderName : gerhard
GroupDomainName : kexpress.net
ComputerDomainName : uk02.kexpress.net
Identifier : 0fc108df-fb03-4a74-9169-5541b5a8d284
DistinguishedName : CN=d237c662-e6ea-40ae-9db9-33e0b28438e2,CN=c696bece-31e6-4823-8a5c-67028d4a2380
,CN=DFSR-LocalSettings,CN=I5-R-DFS-002,CN=Computers,DC=uk02,DC=kexpress,DC=net
ContentPath : C:\shares\gerhard
PrimaryMember : False
StagingPath : C:\shares\gerhard\DfsrPrivate\Staging
StagingPathQuotaInMB : 4096
MinimumFileStagingSize : Size256KB
ConflictAndDeletedPath : C:\shares\gerhard\DfsrPrivate\ConflictAndDeleted
ConflictAndDeletedQuotaInMB : 4096
ReadOnly : False
RemoveDeletedFiles : False
Enabled : True
DfsnPath :
State : Normal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment