2017-08-29 17 views
0

我剛剛瞭解Powershell。我想嘗試更新AD中的數據,但我的AD Server和Powershell位於不同的服務器上。Powershell和ColdFusion使用不同的服務器更新活動目錄

例如,我的AD服務器是111.111.111.111,我的Powershell.exe是服務器222.222.222.222。我正在使用ColdFusion編程來執行我的Powershell腳本。

這裏是我的ColdFusion腳本:

<cfoutput> 
<cfexecute name="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" 
      arguments="C:\Users\Public\Documents\ADtest.ps1" /> 
</cfoutput> 

這裏是我的PowerShell腳本ADtest.ps1:

$userID = "11111" 
$password = "[email protected]" 
$ADuser = Get-ADUser $userID 
If($ADuser) 
{ 
    Enable-ADAccount -Identity $userID 
    Set-adaccountpassword $userID -reset -newpassword (ConvertTo-SecureString -AsPlainText $password -Force) 
    Set-aduser $userID -changepasswordatlogon $true 
} 

是否有可能執行PowerShell腳本來上更新AD(Active Directory)中的數據不同的服務器?

+1

我知道你在學習PowerShell的,但如果最終的目標是用ColdFusion管理AD服務器,它會使用'cfldap'標籤容易得多。 –

回答

1

大多數Powershell的AD命令使用參數-Server用於指定目標DC:

Get-ADUser -Identity $Username -Server $DC 

話雖如此Powershell的通常不與腳本的執行期間切換的DC。

希望幫助-Tom

相關問題