0
私は自分のアカウントでドメイン "domain1"にログインしています。私は、パスワード "password1"を持つsupe ruserアカウント "suaccount"を介してドメイン "domain2"のユーザーを更新できるようにするためにpowershellを使用したいと思っています。両者の間に信頼関係が確立されている。Powershell CMDLETクロスドメイン管理
のPowerShell 2.0と.NET 3.5 SP1
実行私はこれまでのところ得ている:PowerShellのに
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$ctype = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$context = New-Object -TypeName
System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList $ctype, "domain2", "OU=TestOU,DC=domain2", "suaccount", "password1"
$usr = New-Object -TypeName System.DirectoryServices.AccountManagement.UserPrincipal -ArgumentList $context
$usr.Name = "AM Test1"
$usr.DisplayName = "AM Test1"
$usr.GivenName = "AM"
$usr.SurName = "Test1"
$usr.SamAccountName = "AMTest1"
$usr.UserPrincipalName = "[email protected]"
$usr.PasswordNotRequired = $false
$usr.SetPassword("errr")
$usr.Enabled = $true
$usr.Save()
はかなり新しい、任意のポインタを?私は "他の"ドメインのユーザーを編集/作成したいと思っています。
私はエラーを取得する:
"Exception calling "Save" with "0" argument(s): "General access denied error
"
At C:\Script\Sandbox\Morris PowerShell Application\includes\mo\mo.ps1:104 char:14
+ $usr.Save <<<<()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException"
任意のポインタ?
ドメイン2はドメイン1を信頼していますか? –
はい、2つの間に信頼関係が確立されています。 –
Domain2のFQDNは何ですか? –