Leave a comment

Your email address will not be published. Required fields are marked *

2 thoughts on “Get DFS Group Members

  • TerrenceTheTurtle

    $GroupName = “Server1_to_Server2”
    $ServerList = Get-DFSRMember -GroupName $GroupName |
    Select-Object DNSName |
    Sort-Object

    $RootPath = ‘E:SharesExampleRoot’
    $Domain = ‘Contoso.Local’
    $NameSpace= ‘Shares’

    $Shares = Get-SMBShare -special $False|
    Where-Object {$_.path like $RootPath}

    Foreach ($Share in $Shares){

    $Drive = $share.path.split(“:”)[0]
    $ShareName = $Share.Name
    $DFSNFolderTest = get-dfsnfolder \$Domain$NameSpace$ShareName

    if ($DFSNFolderTest){

    write-verbose “$ShareName : DFSNFolder already exists, moving on.”

    }
    else{

    $Params = @{

    path=”\$Domain$NameSpace$ShareName”;
    TargetPath=”\$Env:ComputerName$ShareName”;

    }

    write-verbose “Creating DFSNFolder for $ShareName”
    new-dfsnfolder @params
    }
    }