Can logon script be assigned to a user in a windows machine which is not a part of domain through powershell?

1

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.

cmm user

Posted 2013-12-16T13:13:29.130

Reputation: 143

The duplicate question that this one was closed against no longer exists. There is NO duplicate. – Tog – 2013-12-16T14:44:31.127

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 – 2013-12-16T15:59:14.343

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 – 2013-12-17T05:38:12.433

Answers

0

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

Knuckle-Dragger

Posted 2013-12-16T13:13:29.130

Reputation: 1 817

if it fails, we'll need to add a snip to create the folder structure. – Knuckle-Dragger – 2013-12-17T09:37:09.273

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 – 2013-12-17T10:08:57.890

Change destination, C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup – Knuckle-Dragger – 2013-12-17T10:14:29.823

This worked fine.Thanks. But is it possible to do the same remotely? – cmm user – 2013-12-17T12:16:09.123

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\Start Menu\Programs\Startup – Knuckle-Dragger – 2013-12-17T13:28:24.450

No.I don't want to loop through a list of names.I just want to assign the logon script to a user on a remote machine. – cmm user – 2013-12-18T06:13:44.680

In that case, I'd just throw that C$ path into your destination. Updated the answer retro-actively – Knuckle-Dragger – 2013-12-18T21:15:13.777

I have put the command into a script and then I am running the script file remotely.So that is working fine. I am facing an issue.I have updated the question. – cmm user – 2013-12-19T10:48:13.943