public static string GetDefaultAcceptedDomain(string organization) { using (MyPowerShell ps = new MyPowerShell()) { ps.GetDefaultAcceptedDomain(organization); IEnumerable <PSObject> result = ps.Invoke(); foreach (PSObject item in result) { Dictionary <string, object> properties = CommonCAS.GetPSObjectProperties(item); return(properties["DomainName"].ToString()); } throw new Exception("Unable to find default accepted domain"); } }