Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I've installed PowerShell Version 1.0 on my Windows 2003 server. How do I run a PowerShell script during logon or logoff event? I tried this through

Local Computer policy>User Configuration>Windows Settings>Logon/Logoff Scripts

But it doesn't seem to work.

share|improve this question
up vote 5 down vote accepted

You need to call the powershell binary directly with the scriptname. The example below assumes the .PS1 file is stored within directory assigned to the GPO. You will need to change the variables to match your environment.

powershell.exe -Command ". '\\%SYSVOL%\Policies\%POLICYGUID%\scriptname.ps1'"
share|improve this answer
Thanks jscott. I did the same but made one mistake. My script takes an input argument. Here's what I did when adding the script as logon script in Local computer policy, Script Name: C:\path\to\powershell.exe Script Parameters: -command "& '\\path\to\my\script -input hello' " This is what worked, Script Name: C:\path\to\powershell.exe Script Parameters: -command "& '\\path\to\my\script' -input hello" Note that input argument goes outside of single-quotes. – BlueGene Jul 2 '10 at 15:35

Workaround could be to create a batch script that will execute the Powershell script, then set that in the policy.

(but jscott's answer is better)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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