I am not able to execute the following command in Exchange Management Shell 2019. It returns the error as "you cannot call a method on a null-valued expression"
[PS] C:\>$domain = (Get-DomainController).Identity.DomainId.ToString()
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $domain = (Get-DomainController).Identity.DomainId.ToString()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

