none
Powershell Logon Script Problems

    Question

  • Hello all,

    I have recently written a powershell logon script. For some reason it works fine under XP but will not execute under Windows 7. It shows up in RSOP but I cannot find any reason why it's not running. It's set in group policy under Administrative Templates/System/Logon/Run These Programs at User Logon. My context is as follows "powershell.exe -Command \\**script path**" I can run the script manually but for whatever reason it will not execute in Windows 7 through group policy. Thanks for any help!

    Thursday, February 09, 2012 8:38 PM

Answers

All replies

  • Try replacing it with "powershell.exe -file \\**Script Path**"
    Friday, February 10, 2012 12:50 AM
  • Still the same result :(
    Friday, February 10, 2012 1:15 PM
  • Still the same result :(

    Yu cannot easily execute a remote script during logon unless you have POwerSHell installed on teh remote computers and they hav eall been set to execute remotesigned scripts.  YOu then need to sign the script with an enterprise trusted certificate.

     If PowerShell is instlled on teh remote machines then check the event log for errors on those machines during logon.


    ¯\_(ツ)_/¯

    Friday, February 10, 2012 4:56 PM
  • The remote execution policy is set to unrestricted on the computer I am testing with. On XP the script runs with no issues, on 7 powershell never opens and the script never runs in any way.
    Friday, February 10, 2012 6:25 PM
  • The remote execution policy is set to unrestricted on the computer I am testing with. On XP the script runs with no issues, on 7 powershell never opens and the script never runs in any way.

    And the event log?

    Have you tried to put trace statements in the batch file.  echo to a file before and after the statement.


    ¯\_(ツ)_/¯

    Friday, February 10, 2012 6:30 PM
  • The remote execution policy is set to unrestricted on the computer I am testing with. On XP the script runs with no issues, on 7 powershell never opens and the script never runs in any way.

    And the event log?

    Have you tried to put trace statements in the batch file.  echo to a file before and after the statement.


    ¯\_(ツ)_/¯

    My main issue is that the group policy loads on to the computer, but it does not even attempt to load the powershell script. On XP the powershell command window comes up and runs. On 7 nothing opens and I get no error. Nothing shows up in event viewer. The policy shows in RSOP but never attempts to execute so I don't even get an error.
    Wednesday, February 15, 2012 2:19 PM
  • The PoSh script or batch file aren't invoking something that's present on Windows XP but not Windows 7 are they?
    Wednesday, February 15, 2012 3:09 PM
  • The PoSh script or batch file aren't invoking something that's present on Windows XP but not Windows 7 are they?

    And as a corrolary  - Have you tried to run the scipt at teh console so you can see any error messages.


    ¯\_(ツ)_/¯

    Wednesday, February 15, 2012 4:23 PM
  • The PoSh script or batch file aren't invoking something that's present on Windows XP but not Windows 7 are they?

    And as a corrolary  - Have you tried to run the scipt at teh console so you can see any error messages.


    ¯\_(ツ)_/¯


    No issues running the script in the console. Everything runs just as it should.
    Wednesday, February 15, 2012 5:22 PM
  • The PoSh script or batch file aren't invoking something that's present on Windows XP but not Windows 7 are they?

    And as a corrolary  - Have you tried to run the scipt at teh console so you can see any error messages.


    ¯\_(ツ)_/¯


    No issues running the script in the console. Everything runs just as it should.

    At this point you need to post the script.

    Are you sure you tested it on the exact machine that it fails on.

    Running PowerShell logon scripts is not supported before WS2008R2 as Group Policy is not set up correctly to handle the way PowerShell runs and components required may not be loaded at the time the script is executed.

    Your older XP machines may be just slow enough to prevent this from happening.  Windows 7 is nearly always many times faster at staging a logon which can create problems for some scripts.


    ¯\_(ツ)_/¯



    • Edited by jrv Saturday, February 25, 2012 8:27 PM
    Wednesday, February 15, 2012 5:29 PM
  • Try copying the script locally and use gpedit.msc to create a local PowerShell logon script.  If it runs without issue, then chances are that your Win 7 box is not waiting for network connectivity before processing GPO.

    Rich Prescott | Infrastructure Architect, Windows Engineer and PowerShell blogger | MCITP, MCTS, MCP

    Engineering Efficiency
    @Rich_Prescott
    Windows System Administration tool
    AD User Creation tool

    Sunday, February 19, 2012 9:33 PM