Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用Set-MsolUserLicense命令发送字符串以删除用户的许可证_C#_Azure Powershell - Fatal编程技术网

C# 无法使用Set-MsolUserLicense命令发送字符串以删除用户的许可证

C# 无法使用Set-MsolUserLicense命令发送字符串以删除用户的许可证,c#,azure-powershell,C#,Azure Powershell,我正在尝试使用c#中的Set MsolUserLicenseMsol Powershell命令从具有字符串的用户删除许可证 string removeLicense = "Set-MsolUserLicense -UserPrincipalName " + "\"" + selectedUPN + "\"" + " -RemoveLicenses " + accountSkuId + ":ENTERPRISEPACK"; 其中selectedUPN是从文本框中获取的选定选项 不知何故,它不

我正在尝试使用c#中的
Set MsolUserLicense
Msol Powershell命令从具有字符串的用户删除许可证

string removeLicense = "Set-MsolUserLicense -UserPrincipalName " + "\"" 
+  selectedUPN + "\"" + " -RemoveLicenses " + accountSkuId + ":ENTERPRISEPACK";
其中selectedUPN是从文本框中获取的选定选项


不知何故,它不接受字符串,但如果我在removelicense字符串中按字面意思键入UPN,它就会工作。

最终成功地将此排序…创建的字符串如下所示,并且工作正常:


string removeLicense=“Set-MsolUserLicense-UserPrincipalName\”“+selectedUPN+”\“-RemoveLicenses”+accountSkuId+”:ENTERPRISEPACK”

我的意思是,如果我从上面删除字符串selectedUPN,并在字符串removeLicense中手动添加UPN来处理该命令,它就会工作。您是否收到任何返回的消息?也许您不需要引号来包装selectedUPN,您应该在两个参数值周围加上引号。