如何设置使用新ADUser便有使用PowerShell环境选项卡上的值?便有、卡上、如何设置、选项

2023-09-08 13:07:38 作者:失梦少年

我使用PowerShell脚本从一个CSV文件添加用户,但我一直无法找到一个方法来Environment选项卡上设置的值。我曾试过用

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"}

无济于事。 我使用的服务器2008 R2。这里是标签我所说的:

to no avail. I am using Server 2008 R2. Here is the tab I am talking about:

我如何设置这些值?

推荐答案

如果任何人有兴趣:

$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

 
精彩推荐