问题
I am using a PowerShell script to add users from a CSV file, but I have been unable to find a way to set the values on the Environment tab. I have tried using
-OtherAttributes @{'msTSInitialProgram'="programToRun"; 'msTSWorkDirectory'="directoryToRunIn"}
to no avail. I am using Server 2008 R2. Here is the tab I am talking about:

How can I set these values?
回答1:
If anyone else is interested:
$dn = (Get-ADUser $user).DistinguishedName
$ext = [ADSI]"LDAP://$dn"
$ext.PSBase.InvokeSet("TerminalServicesInitialProgram","C:\Temp\test.bat")
$ext.PSBase.InvokeSet("TerminalServicesWorkDirectory","C:\Temp\TestingToTheBone")
$ext.SetInfo()
sets the values on this tab.
http://gallery.technet.microsoft.com/scriptcenter/PowerShell-Create-Active-7e6a3978/view/Discussions
来源:https://stackoverflow.com/questions/26161067/how-can-i-set-the-values-on-the-environment-tab-using-new-aduser-with-powershell