簡體   English   中英

如何在ASP.NET中使用Powershell和System.Management.Automation更新字段extensionAttribute3?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM