Announcement

Collapse
No announcement yet.

Executing PS scripts via logon scripts

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Executing PS scripts via logon scripts

    Hi all,
    Again thank you for all your help and time.
    I need to make sure that the Telnet service is enabled and running on all the machines in the office about 50 of them.
    I found that even when I set the service to automatic and start on some machines the service is being disabled after a few days – not sure way I am investigating this.
    I can use the net start and net use to start the service but it will have to be set to Automatic in the properties therefore I thought by running the script below and change the settings of the Telnet service to Automatic I will be able to run the batch file straight after.
    “set-service TlntSvr -startuptype automatic”
    What will be the best way of running this PS scripts on my 50 machines in the office.
    I have looked to use it in my logon scripts but not sure how to use PS with logon scripts.

    Thank you!
    Avi

  • #2
    Re: Executing PS scripts via logon scripts

    Instead of using powershell you could also use a dos-command:
    configure startup script,
    1. Script Name:
      SC.exe
      Script Parameters:
      config TlntSvr start= auto

    2. Script Name:
      SC.exe
      Script Parameters:
      start TlntSvr


    Powershell:
    configure startup script,
    1. Script Name:
      powershell.exe
      Script Parameters:
      -noexit set-service TlntSvr -startuptype automatic


    To run a Windows PowerShell script as part of a logon vbscript:
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "powershell.exe -noexit set-service TlntSvr -startuptype automatic"



    \Rems
    Last edited by Rems; 26th August 2010, 15:08.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Executing PS scripts via logon scripts

      Hi Rems,

      Thank you for your help.
      I used GPO to set the telnet to Automatic (this was suggested by another user of this site)
      Then use a simple script with the net start which I added to the logon script I can make sure that the Telnet service is running.

      I have a question for you in regards to the last part:
      "To run a Windows PowerShell script as part of a logon vbscript:
      Set objShell = CreateObject("Wscript.Shell")
      objShell.Run "powershell.exe -noexit set-service TlntSvr -startuptype automatic"

      Where do I put this script and how to I save it? I understand the "programming" but I am confused when it is coming to use it.

      Again thank you for your help

      Avi

      Comment


      • #4
        Re: Executing PS scripts via logon scripts

        Originally posted by Avi View Post
        Hi Rems,

        Thank you for your help.
        I used GPO to set the telnet to Automatic (this was suggested by another user of this site)
        Then use a simple script with the net start which I added to the logon script I can make sure that the Telnet service is running.
        (This was the thread about configure a service at startup, GPO Forum: "Start the Telnet service via GPO in server 2008R2")


        Originally posted by Avi View Post
        I have a question for you in regards to the last part:
        "To run a Windows PowerShell script as part of a logon vbscript:
        Set objShell = CreateObject("Wscript.Shell")
        objShell.Run "powershell.exe -noexit set-service TlntSvr -startuptype automatic"

        Where do I put this script and how to I save it? I understand the "programming" but I am confused when it is coming to use it.

        Again thank you for your help

        Avi
        You can execute PS-scripts or run cmdlets from within a batch or vbscript or by command line from a dos-prompt. Just by starting the command with powershell.exe -noexit
        The sample in my previous post is a VBscript (*.vbs).
        It is possible to run vbscripts also as logon or as startup scripts by GPO (on the same way you run batch-files or exe-files with a gpo).

        Note 1 - a compatible version of Powershell should be installed on the clients!
        Note 2 - for this sample better to use a computer startup script instead of a user logon script as users are not allowed to make changes to setting of services.

        \Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment


        • #5
          Re: Executing PS scripts via logon scripts

          Thanks for all the help guys.

          Rem I am going to have a look at the startup scripts and the logon scripts to see what will be the best option.

          Again thank you all for your help

          Avi

          Comment

          Working...
          X