[英]ASP.NET 5 MVC 6 System.Management.Automation issue with DNX
[英]How I can update the Field extensionAttribute3 with Powershell and System.Management.Automation in ASP.NET`?
NET应用程序,我想更新活动目录中的信息。 为此,我使用System.Management.Automation命名空间。 这样,我就可以使用Powershell了。 它工作正常,但我不知道如何更新字段“ extensionAttribute3”(这是我们的Costcenter)。
这是我的代码:
...
PSCredential crend = new PSCredential(ADNAME, pw);
using (Runspace runspace = RunspaceFactory.CreateRunspace(initial))
{
runspace.Open();
using (Pipeline p = runspace.CreatePipeline())
{
Command command = new Command("Set-ADUser");
command.Parameters.Add("Identity", sAMAccountName);
//command.Parameters.Add("extensionAttribute3", CostCenter); ???
command.Parameters.Add("Description", Description);
command.Parameters.Add("Credential", crend);
p.Commands.Add(command);
p.Invoke();
}
}
...
Set-ADUser cmdlet没有所有可能属性的参数。 对于没有专用参数的属性,可以使用-Add,-Replace和-Remove参数,并为它们提供属性名称和值的哈希表参数。 如果语法完全正确,则不能确定是否正确,但是类似这样:
command.Parameters.Add("Replace",@{extensionAttribute3='CostCenter'})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.