Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is the suggested way to add a logon script to a local user in Windows. http://technet.microsoft.com/en-us/library/cc770908.aspx

Edited:

I also found the following : http://technet.microsoft.com/en-us/library/cc771314.aspx

Is it possible to add a logon script to a user through Local Users and Groups tab in Computer Management using powershell?

Update :

I am able to copy the script file to the location -\%COMPUTERNAME%\C$\Users\%username%\AppData\Roaming\Microsoft\Windows\Star‌​t Menu\Programs\Startup' and it runs successfully. But in the local user properties I am not able to set the value of the attribute 'Logon script' to the desired value.

share|improve this question
    
The duplicate question that this one was closed against no longer exists. There is NO duplicate. – Tog Dec 16 '13 at 14:44
    
Just to clarify, you're wanting to assign a script using PowerShell, vs the local group policy editor? As in, the script will assign the startup script? – Tanner Faulkner Dec 16 '13 at 15:59
    
Actually I want to do the script assignment through powershell script and not manually through local group policy editor. Is there a way to do that? – cmm user Dec 17 '13 at 5:38

I put my logon scripts in this folder.

C:\Windows\System32\GroupPolicy\User\Scripts\Logon

So to answer

Copy-Item 'C:\temp\MyLogonScript.ps1' -destination 'C:\Windows\System32\GroupPolicy\User\Scripts\Logon'
#

Edit: To install a logon script per user remotely, use this command. Don't forget to edit the %COMPUTERNAME% and %username%

Copy-Item 'C:\temp\MyLogonScript.ps1' -destination '\\%COMPUTERNAME%\C$\Users\%username%\AppData\Roaming\Microsoft\Windows\Star‌​t Menu\Programs\Startup
share|improve this answer
    
if it fails, we'll need to add a snip to create the folder structure. – Knuckle-Dragger Dec 17 '13 at 9:37
    
Hi Knuckle.. I have found a different way to add the logon script.Rather than adding the script to the group policy the script can be added to the user. I have edited my post with the link having the steps to perform the operation. Can this be done through powershell? – cmm user Dec 17 '13 at 10:08
    
Change destination, C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup – Knuckle-Dragger Dec 17 '13 at 10:14
    
This worked fine.Thanks. But is it possible to do the same remotely? – cmm user Dec 17 '13 at 12:16
    
So you want to loop through a list of names from a text file ? We can copy the file over the $admin shares \\$SERVERNAMEVARIABLE\C$\Users\%username%\AppData\Roaming\Microsoft\Windows\Star‌​t Menu\Programs\Startup – Knuckle-Dragger Dec 17 '13 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .