How can I set the values on the Environment tab using New-ADUser with PowerShell?

China☆狼群 提交于 2020-01-05 23:21:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!