PowerShell logon script


  1. Posts : 2
    Windows 7 Professional 32bit
       #1

    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 Computer


  2. Posts : 1
    Windows 7 Ultimate x64
       #2

    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 Computer


 

  Related Discussions
Our Sites
Site Links
About 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 03:24.
Find Us