Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.



Windows 7: PowerShell logon script

24 Aug 2010   #1

Windows 7 Professional 32bit
 
 
PowerShell logon script

Ok, so this doesn't necessarily have to do with Windows 7, but I originally wanted to reply to a post on Vista forums and somehow I ended up here. Anyway...

I actually tried all of this on Windows Server 2008 - set policies, scripts and logged on there.
Here's one way that actually works. 1) created a logonScript.ps1 file with whatever in it for the actual logon script. 2) created GPO with a policy for running a logon script and specified a vbScript file: launcher.vbs. 3) put those two files in the same folder related to the policy if you know what I mean.
The launcher.vbs contains:
[
' set up objects
Set WshShl = WScript.CreateObject("WScript.Shell")
Set fileSys = CreateObject("Scripting.FileSystemObject")
Set scriptFile = fileSys.GetFile("logonScript.ps1")

WshShl.Run("PowerShell.exe -NoLogo -NoProfile -command ""&{set-executionpolicy Unrestricted;&'" & scriptFile & "'}""")
]
That last line causes something like:
'PowerShell.exe -NoLogo -NoProfile -command "&{set-executionpolicy Unrestricted;&'\\IT270\sysvol\IT270.com\Policies\{AAD5280F-A3B7-4F65-B15B-27E6F92BA431}\User\Scripts\Logon\logonScript.ps1'}"
to run.
The one remaining problem is that I still get a prompt asking me if I want to run the script or not. If I set the IE intranet zone trusted sites to have file://IT270 then that prompt goes away. Unfortunately, setting it with Group Policy didn't work. I had to do it manually or individually in any case. I have another idea of how to get around this: copy the script down to the local computer (TEMP directory) with the VBscript and then invoke it from there.
Ok, I know this is all pretty ridiculous and probably way more effort than it's worth, but it's an exercise. I wanted to make it happen and it works with PS v.1. I guess if I wanted to get really ridiculous, I could just drag out the entire script into the command line I created above. Though, it probably has a max characters limit or something.

My System SpecsSystem Spec
29 May 2011   #2

Windows 7 Ultimate x64
 
 

I've also created a Powershell login script here which I run not using Group Policy but from the user's AD account as part of their actual login script.

Powershell login script to map network drives, printers and applicaton settings

Hope this helps others out.
My System SpecsSystem Spec
Reply

 PowerShell logon script





Thread Tools



Similar help and support threads for2: PowerShell logon script
Thread Forum
CMD or Powershell Moving - script not working General Discussion
powershell script to create user folders and set permissions Software
Logon script not running on Win 7 General Discussion
Script Logon into websites Software
Logon script issue... Network & Sharing
Logon Script Network & Sharing
Install SysInternals Suite using PowerShell INF Script Software

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:33 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33