DFSR configuration using powershell

DFS – Distributed File System is a feature from Microsoft. As the name says, DFS is a service used to organize distributed file shares to distributed file system.There are two components for

DFS: Replication and Namespace. Both are independent services hence it can be used without installing the other.
This article is intended to give you a powershell script which will help you install and configure DFS-Replication service. Make sure that you have powershell DFS-R modules before proceeding with the script.

Install DFS-R on the go:

####################################################
# Script Provided by Vysakh Venugopal (https://systemadminguide.wordpress.com)
# This powershell script is used for installing any windows feature.
# Has 2 parts - one, default installation (DFS-Namespace and DFS-Replication).
# Two, Install a feature based on users choice.
#
####################################################
# Save error preference then stop this script on the first error.
$prevErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = "Stop"
Write-Host "DFS-R Installation and Configuration is about to start.."
# Importing ServerManager Module
Import-Module ServerManager
$option = Read-Host "Type 0 for default feature(s) installation, else type 1"
# Condition Validation - Default Installation
if($option -eq "0")
{
Write-Host "Checking for installed features..."
$dfs=Get-WindowsFeature *DFS-R*
$rsat=Get-WindowsFeature *RSAT-DFS-M*
 if(-not($dfs.Installed) -and -not($rsat.Installed)) {
 Write-Host "Installing windows feature(s): Default" Add-WindowsFeature FS-DFS-Replication, RSAT-DFS-Mgmt-Con
 }elseif(-not($dfs.Installed) -and $rsat.installed)  {
 Write-Host "DFS Replication is now being installed.."
 Add-WindowsFeature FS-DFS-Replication
 }elseif(-not($rsat.Installed) -and $dfs.installed)  {
 Write-Host "DFS Management Tool is being installed.."
 Add-WindowsFeature RSAT-DFS-Mgmt-Con
 }elseif($dfs.Installed -and $rsat.Installed)
 {
 Write-Host "DFS is already installed."
 }
 $conf = Read-Host "Do you want to configure DFS right away (y/n)?"
 if(($conf -eq "y") -or ($conf -eq "Y"))
 {
 Invoke-Expression "C:\Configure_DFSR.ps1" 
 }elseif(($conf -eq "n") -or ($conf -eq "N"))
 {
 Write-Host "Exiting as user don't want to configure DFSR."
 }else
 {
 Write-Host "Invalid Option!!"
 }
}
# Condition Validation - User Defined Feature Installation
elseif ($option -eq "1")
{
Get-WindowsFeature
$install_feature = Read-Host "Type feature name from the above list:"
Write-Host "Installing windows feature(s): $install_feature"
Add-WindowsFeature $install_feature
}
# Exiting without installation
else
{
Write-Host "Invalid Option!!Exiting"
}

Configure DFS-R:

Thanks to Microsoft team who has provided such a nice script. You can download a copy of the script:
Configure_DFSR.

Found any errors while executing this? Let me know through comments so that I can help you out with the solution.

LET US KNOW YOUR RATINGS ON THIS BLOG HERE. ALSO FEEL FREE TO CONTACT ME.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s