2012-02-08 11 views
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" 

任意のポインタ?

+1

ドメイン2はドメイン1を信頼していますか? –

+0

はい、2つの間に信頼関係が確立されています。 –

+0

Domain2のFQDNは何ですか? –

答えて

0

コメントから:この形式domain2 \ usernameというユーザー名を使用してみてください。常にドメインのFQDNを使用してください。 - 昨日のキリスト教徒

関連する問題