-1

I have used the "New-ADUser" command to create a batch of new user. However, I need to set the "Program file name" in "Starting program" to "c:\windows\system32\logoff.exe" and "Start in" to "c:\windows\system32\".

Starting program

Also I need to untick "Require user's permission" in "Remote control"

Remote control

How can I set these by powershell? Many thanks.

0

Googling for powershell "start the following program at logon" yields this result:

Copy&paste from the accepted answer:

$ou = [adsi]"WinNT://127.0.0.1"
$user = $ou.psbase.get_children().find("test")
$user.PSBase.InvokeSet("TerminalServicesInitialProgram", "C:\logoff.bat")
$user.setinfo()

Googling for powershell "require users permission" yields this result:

$user = [ADSI]"LDAP://CN=UserName,DC=Contoso,DC=Com"
$user.InvokeSet("EnableRemoteControl",2)
$user.SetInfo()

Or, from the same thread using the Quest active directory tools:

Get-QADUser Kazun | Set-QADUser -TsRemoteControl 2

Possible values for RemoteControl:

Disable 0 (0x0)
Remote control is disabled.

EnableInputNotify 1 (0x1)
The user of remote control has full control of the user's session, with the user's permission.

EnableInputNoNotify 2 (0x2)
The user of remote control has full control of the user's session; the user's permission is not required.

EnableNoInputNotify 3 (0x3)
The user of remote control can view the session remotely, with the user's permission; the remote user cannot actively control the session.

EnableNoInputNoNotify 4 (0x4)
The user of remote control can view the session remotely, but not actively control the session; the user's permission is not required.

  • I found that "Program file name" use $user.invokeset("TerminalServicesInitialProgram", "C:\logoff.bat") and "Start in" use $user.invokeset("TerminalServicesWorkDirectory", "C:\") – cache chui Jun 13 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.