Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Add new dfsroot target with powerhsell

$
0
0

Hi

I am running below script for remote servers to do below task for windows 2012 servers.
But this script is not able to add new dfsroot target servers

sometime it works for random servers but some of server don't add new dfsroot target server.
why so happening.

Tasks:

Install DFS role on remote server from input file.
Create DFSRoot folders on remote servers in default directory C:\DFSRoots.
Assign read share permission to everyone.
Add New DFS root target Server in existing domain’s DFS namespace.
Output of logs file of all action performed by script.



$DFSFolder = Import-Csv "D:\DFSScript\DFSRoot.csv"
$computers = Get-content "D:\DFSScript\dfsservername.txt" | % {$_ }
$OutputFileLocation = "D:\DFSScript\Scriptoutput.csv"


Start-Transcript -path $OutputFileLocation -Append


import-module ServerManager
Invoke-Command -ComputerName $computers -ScriptBlock {Install-WindowsFeature -Name FS-DFS-Namespace,RSAT-DFS-Mgmt-Con}

$DFSFolder | % {
$DFSRoots = $_.DFSRoot
$Servers = $_.Server
Invoke-Command -ComputerName $computers -ScriptBlock `
{param ($DFSRoots) New-Item -Path C:\DFSRoots\$DFSRoots -ItemType Directory;NET SHARE $DFSRoots=C:\DFSRoots\$DFSRoots /GRANT:Everyone`,READ } -ArgumentList $DFSRoots
dfsutil target add "\\$computers\$DFSRoots"
}

Stop-Transcript

How can add dfsroot target servers on remote computers.. any help pelease


Viewing all articles
Browse latest Browse all 6937

Trending Articles