通过交换从用户中删除 SIP 地址
Remove a SIP address from user via exchange
我正在尝试通过我的 C# 应用程序仅从用户帐户中删除 SIP 地址。我可以使用以下命令通过交换管理 shell 成功删除它。
Set-Mailbox "identity" -EmailAddresses @{Remove="sip: firstname.lastname@domain.com"}
在我的 C# 应用程序中,我有以下内容,但我不确定如何在其中获取“@{Remove="sip:firstname.lastname@domain.com"}”。
string termUserEmail = txtboxTermFirstName + "." + txtboxTermLastName + "@domain.com";
PSCommand command1 = new PSCommand();
command1.AddCommand("Set-Mailbox");
command1.AddParameter("Identity", termUserEmail);
var sipAddress = new Hashtable();
sipAddress.Add("remove", termUserEmail);
command1.AddParameter("EmailAddresses", sipAddress);
所以,我不确定如何让这个东西正确执行命令。我确实看过 C# - Remove Exchange Email Address via Powershell Runspace,这让我走到了这一步。
经过大量的努力,我已经开始做这件事了。我误以为我需要双引号。当我发出 ps 命令时,它为我添加了我不知道的引号。所以基本上这是一个简单的修复。
//删除sip地址
string idTermEmail = "sip:" + txtTermFirstName.Text + "." + txtTermLastName.Text + "@domain.com";
PSCommand command3 = new PSCommand();
command3.AddCommand("Set-Mailbox");
command3.AddParameter("Identity", username);
var sipAddress = new Hashtable();
sipAddress.Add("remove", idTermEmail);
command3.AddParameter("EmailAddresses", sipAddress);
powershell.Commands = command3;
powershell.Invoke();
Wam bam 谢谢女士,一切都已完成。我希望其他人能从中得到一些用处 ;)
我正在尝试通过我的 C# 应用程序仅从用户帐户中删除 SIP 地址。我可以使用以下命令通过交换管理 shell 成功删除它。
Set-Mailbox "identity" -EmailAddresses @{Remove="sip: firstname.lastname@domain.com"}
在我的 C# 应用程序中,我有以下内容,但我不确定如何在其中获取“@{Remove="sip:firstname.lastname@domain.com"}”。
string termUserEmail = txtboxTermFirstName + "." + txtboxTermLastName + "@domain.com";
PSCommand command1 = new PSCommand();
command1.AddCommand("Set-Mailbox");
command1.AddParameter("Identity", termUserEmail);
var sipAddress = new Hashtable();
sipAddress.Add("remove", termUserEmail);
command1.AddParameter("EmailAddresses", sipAddress);
所以,我不确定如何让这个东西正确执行命令。我确实看过 C# - Remove Exchange Email Address via Powershell Runspace,这让我走到了这一步。
经过大量的努力,我已经开始做这件事了。我误以为我需要双引号。当我发出 ps 命令时,它为我添加了我不知道的引号。所以基本上这是一个简单的修复。
//删除sip地址
string idTermEmail = "sip:" + txtTermFirstName.Text + "." + txtTermLastName.Text + "@domain.com";
PSCommand command3 = new PSCommand();
command3.AddCommand("Set-Mailbox");
command3.AddParameter("Identity", username);
var sipAddress = new Hashtable();
sipAddress.Add("remove", idTermEmail);
command3.AddParameter("EmailAddresses", sipAddress);
powershell.Commands = command3;
powershell.Invoke();
Wam bam 谢谢女士,一切都已完成。我希望其他人能从中得到一些用处 ;)