0
我想在C#中使用System.Automation dll運行Exchange cmdlet。在C#powershell運行空間中轉義單引號
在http://technet.microsoft.com/en-us/library/dd315325.aspx,他們紛紛表示,對於逃逸單引號,我們基本上都需要與其他單引號
例如其追加,
[PS] C:\Windows\system32>Write-Host 'Live and let le''arn'
Live and let le'arn
然而,當我試圖做同樣的事情使用我的cmdlet,
New-Mailbox -Name 'user1.''.cn'
新的郵箱實際上是以用戶的姓名創建的''。cn。我們希望它是用戶的CN 代碼來執行此cmdlet如下:。
AutomatedRunspace.Command command = new AutomatedRunspace.Command(cmdlet.Command);
foreach (CmdletParameter param in cmdlet.GetParameters())
{
command.Parameters.Add(param.Name, param.Value);
}
pipeline.Commands.Add(command);
有什麼我們能做的正確逃生呢?