DFSR - Setting MaxOfflineTimeInDays resets RPC port

Nick T 1 Reputation point
2021-03-16T15:57:46.427+00:00

I am using Windows Server 2016 and am attempting to set the DFSR attribute MaxOfflineTimeInDays. The script line I am using is resetting the static RPC port I have set. To set the static RPC port I used the following cmdlet set-dfsrserviceconfiguration -rpcport <static rpc port number> I checked this using both get-dfsrserviceconfiguration and get-ciminstance -namespace root/microsoftdfs -query "select * from dfsrmachineconfig" I could not find a powershell cmdlet to set the maxofflinetimeofdays so I then run the following command to set the attribute set-ciminstance -namespace root/microsoftdfs -query "select maxofflinetimeindays from dfsrmachineconfig" -property @{maxofflinetimeindays=180} This has the side effect of resetting the RPCPort to 0 and setting the DynamicRPCPort to false in output from get-dfsrserviceconfiguration Conversely, using the command set-ciminstance -namespace root/microsoftdfs -query "select rpcportassignment from dfsrmachineconfig" -property @{rpcportassignment=<staticrpc port number} results in the maxofflinetimeindays being reset to the default (60 in my case) Using the command wmic.exe /namespace:\root\microsoftdfs path dfsrMachineConfig Set MaxOfflineTimeInDays=180 does not result in the RPCPort being reset so I do have a way forward Any thoughts?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,418 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Dmitry Rabinovich 5 Reputation points
    2023-12-13T18:22:58.7433333+00:00

    Start > Run > cmd > Type the following command:

    "wmic.exe /namespace:\\root\microsoftdfs path DfsrMachineConfig set MaxOfflineTimeInDays = 999"

    Verify the MaxOffline attribute has changed successfully to 999. Type the following command:

    "wmic.exe /namespace:\\root\microsoftdfs path DfsrMachineConfig get MaxOfflineTimeInDays"

    Note: Remove the quotes.

    $dfsrPath = Get-WmiObject -Namespace root\microsoftdfs -Class DfsrMachineConfig
    $currentValue = $dfsrPath.MaxOfflineTimeInDays
    $requiredValue = "999"
    
    if(!($currentValue -eq $requiredValue)){
            Write-Host "Required value does not exist"
            Write-Host "Current value: $currentValue"
            Write-Host "Required value: $requiredValue"
            Write-Host -Verbose "Going to set MaxOfflineTimeInDays value"
            Set-CimInstance -namespace root/microsoftdfs -query "select maxofflinetimeindays from dfsrmachineconfig" -property @{maxofflinetimeindays=$requiredValue}
    
     }
    else{
    
            Write-Host "The value of MaxOfflineTimeInDays already Exists. No Action Required"
            Write-Host "Current value: $currentValue"
            Write-Host "Required value: $requiredValue"
    }
    
    1 person found this answer helpful.

  2. Rich Matheisen 45,186 Reputation points
    2021-03-16T18:46:39.287+00:00
    0 comments No comments