/// <summary>
        /// Executes the user verify and returns a list of strings with results suitable for display
        /// </summary>
        public List<String> O365Verify(string userupn, string userdomain)
        {
            LocalUserFactory LocalUser = new LocalUserFactory(userdomain);
            List<String> retvalue = new List<String>();
            using (CmdletExecutor cmdlet = new CmdletExecutor(adminusername, password, ToStringHints))
            {
                NameValueCollection localuser = LocalUser.GetUserProperties(userupn);
                if (localuser == null)
                {
                    retvalue.Add("FAILED to get properties for on-prem user");
                    return retvalue;
                }
                cmdlet.LoginToOffice365();
                foreach (VerifyRule rule in verify_rules)
                {
                    retvalue.Add("Verifying rule:" + rule.CommandName);
                    NameValueCollection ruleparam = new NameValueCollection();
                    ruleparam[rule.ArgumentName] = ReplaceUPN(rule.ArgumentValue, userupn);
                    string ErrorOutput = "";

                    NameValueCollection o365user = cmdlet.ExecuteCommand(rule.CommandName, ruleparam, rule.PSType, ref ErrorOutput);
                    if (ErrorOutput.Length > 0)
                        retvalue.Add("FAILED to execute:" + ErrorOutput);
                    else
                    {
                        foreach (MatchProperty match in rule.Matches)
                        {
                            string matchinfo = "";
                            bool matchresult = match.IsMatch(o365user, localuser, ref matchinfo);
                            if (matchresult)
                                retvalue.Add("Matched " + match.PropertyName);
                            else
                                retvalue.Add("FAILED match:" + match.PropertyName + " values:" + matchinfo);
                        }
                    }
                }
            }
            return retvalue;
        }
 /// <summary>
 /// Sets the user's UPN back to the onmicrosoft.com UPN, then set it back to the original again, fixes a lot of 
 /// "interesting" O365 issues (assumes adminusername domain is the onmicrosoft.com domain)
 /// </summary>
 public bool ResetUPN(string userupn)
 {
     bool result = false;
     if (adminusername.ToLower().EndsWith("onmicrosoft.com"))
     {
         string[] defaultDomainParts = adminusername.Split("@".ToCharArray());
         if (defaultDomainParts.Length == 2)
         {
             string defaultDomain = defaultDomainParts[1];
             using (CmdletExecutor cmdlet = new CmdletExecutor(adminusername, password, ToStringHints))
             {
                 cmdlet.LoginToOffice365();
                 NameValueCollection setparams = new NameValueCollection();
                 string error_output = "";
                 string onmicrosoft_upn = userupn.Split("@".ToCharArray())[0]+"@"+defaultDomain;
                 setparams.Add("UserPrincipalName",userupn);
                 setparams.Add("NewUserPrincipalName", onmicrosoft_upn);
                 cmdlet.ExecuteCommand("Set-MsolUserPrincipalName", setparams, PowershellType.MSOL, ref error_output);
                 if (error_output.Length <= 0)
                 {
                     // now set it back to normal
                     setparams.Clear();
                     setparams.Add("UserPrincipalName", onmicrosoft_upn);
                     setparams.Add("NewUserPrincipalName", userupn);
                     cmdlet.ExecuteCommand("Set-MsolUserPrincipalName", setparams, PowershellType.MSOL, ref error_output);
                     result = error_output.Length <= 0;
                 }
             }
         }
     }
     return result;
 }