none
Automate DFSR deployment via PowerShell Scripting - Operation Error Occured RRS feed

  • Question

  • have been trying to script the deployment of DFSR through Powershell and found a way to do this interactively, but not automatically during bootstrapping (with AWS).  However, when I try to do this from an elevated-session (as Domain Admin) to a remote system I receive the error:  "Could not create the replication group named "Group". An operation error occurred."   No where can I see why the error occurred. 

    I am not asking for help in writing the script, but merely asking if anyone has run across this error and if this is actually possible to script DFSR configuration via powershell in this manner.

    There are no event log entries made which makes this really hard to troubleshoot.  Here is more information on my environment.  

    Two Windows 2012 R2 Servers both with DFSR feature installed (with Management tools) and installed by my script.

    Both servers are a member of the same DOMAIN.

    I am logged in locally to the servers using local account (not domain account) to mimic the tests as the boot strapping process of AWS cfn-init utilizes the local administrator account for bootstrapping (i believe).

    Here is the excerpt of the script I am running.. pretty simple... where I am invoking a remote session as a domain/admin and executing the content of the script in each remote session.  Note: it is not complete, as this does not add members, connections, replication folder, etc..   I wanted to post this for feedback as if I can not create the Replication Group then I can not do the other items.

    ##########################################################
    ##########################################################
    
    <# 
    This script will temporarily store the user account password in encrypted form for use in 
    AWS Bootstrapping only.  Once the bootstrap process has completed the needed tasks, 
    all files will be removed from the instance.
    #>
    
    param (
        [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true,
            HelpMessage='Please specify the Primary server name where PS Session will be launched.')]
        [ValidateNotNullOrEmpty()]
        [string]$PrimaryServer,
    
    	[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true,
            HelpMessage='Please specify the Secondary server name where PS Session will be launched.')]
        [ValidateNotNullOrEmpty()]
        [string]$SecondaryServer,
    
        [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true,
            HelpMessage='Please specify a DOMAIN Admin User Name in <Domain>\<Username> format.')]
        [ValidateNotNullOrEmpty()]
        [string]$DomainUserName,
    
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,
            HelpMessage='Please specify a content folder path.')]
        [ValidateNotNullOrEmpty()]
        [string]$ContentPath,
    
    	[Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true,
            HelpMessage='Please specify a unique replication group name.')]
        [ValidateNotNullOrEmpty()]
        [string]$GroupName,
    
        [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,
            HelpMessage='Please specify a replicated folder name.')]
        [ValidateNotNullOrEmpty()]
        [string]$FolderName
    )
    
    $script1 = {
    Param($PrimaryServer)
    write-host "this is now in script1"
    write-host $PrimaryServer
    
     
    set-executionpolicy unrestricted -force
    
    # Install Windows Features for DFSReplication with Management Tools
    
    $feat1 = Install-WindowsFeature FS-DFS-Replication -IncludeManagementTools -ComputerName $PrimaryServer
    Write-Host $feat1 | Out-File C:\\cfn\script1_output.txt
    }
    
    $script2 = {
    Param($SecondaryServer)
    write-host "this is now in script2"
    write-host $SecondaryServer
     
    set-executionpolicy unrestricted -force
    
    # Install Windows Features for DFSReplication with Management Tools
    
    $feat2 = Install-WindowsFeature FS-DFS-Replication -IncludeManagementTools -ComputerName $SecondaryServer
    Write-Host $feat2 | Out-File C:\\cfn\script2_output.txt
    pause
    }
    
    $script3 = {
    Param($PrimaryServer,$SecondaryServer,$GroupName,$FolderName,$ContentPath)
    	Write-Host "this is now script3 performing activity from session1 as DOMAIN Admin"
    
    	$servers = "$PrimaryServer,$SecondaryServer"
    	Write-Host $servers
    
    	$feat3 = C:\\cfn\\DFSRps-microsoft.ps1 -GroupName $GroupName -FolderName $FolderName -ComputerName $servers -PrimaryComputerName $PrimaryServer -ContentPath $ContentPath -Verbose
    	Write-Host $feat3 | Out-File C:\\cfn\\script3_output.txt
    }
    
    # Set Variables
    $user = $DomainUserName
    $keyfile='C:\cfn\dfsr.key'
    $PasswordFile = 'C:\cfn\dfsr.bin'
    $password = Get-Content $PasswordFile| ConvertTo-SecureString -Key (Get-Content $keyfile)
    $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $user,$password
    
    # Create PS session on defined computer and reference session in $s variable
    
    $s1 = New-PSSession -ComputerName $PrimaryServer -Credential $cred
    $s2 = New-Pssession -ComputerName $SecondaryServer -Credential $cred
    
    
    # Begin process of generating an enryption key and temporarily storing domain admin credentials as secure file on local machine.
    
    Invoke-Command -Session $s1 -ScriptBlock $script1 -ArgumentList $PrimaryServer  
    Invoke-Command -Session $s2 -ScriptBlock $script2 -ArgumentList $SecondaryServer 
    Invoke-Command -Session $s1 -ScriptBlock $script3 -ArgumentList $GroupName $FolderName $PrimaryServer $SecondaryServer $ContentPath 

    Thursday, November 3, 2016 1:07 AM

All replies

  • We cannot even tell which line caused this because you didn't post the whole error.

    Do not post screen shots. Copy the error and paste it here.  Your image is just a fuzzy blur.

    Also AWS is not a Microsoft product so you may need to post in an AWS forum.


    \_(ツ)_/

    Thursday, November 3, 2016 1:33 AM
  • Here is the error.  

    Could not create the replication group named "Group". An operation error occurred.
        + CategoryInfo          : NotSpecified: (System.String[]:String[]) [New-DfsReplicationGroup], DfsrException
        + FullyQualifiedErrorId : New-DfsReplicationGroup.TerminatingOMException,Microsoft.DistributedFileSystemReplicatio
       n.Commands.NewDfsReplicationGroupCommand
        + PSComputerName        : E3AZ1FS1
    

    This manifests itself even when running interactively through ISE or simply through a Powershell session. 

    In regards to AWS, I am not looking for support there... I am simply trying to troubleshoot this from a Microsoft scripting perspective since this is Microsoft product where the error is being manifested.

    Thursday, November 3, 2016 3:55 PM
  • Does anyone have any thoughts? I am kind of stuck at the moment..
    Monday, November 7, 2016 7:01 PM