Run script after session login in PSWA

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Abel Ferreira Abel Ferreira 1 year, 3 months ago.

  • Author
  • #27676
    Profile photo of Abel Ferreira
    Abel Ferreira


    I installed PSWA so that my remote technical users have access to some admin functions, like reset office 365 user password, restart application service, etc...

    But i don't want they have access to all powershell cmdlets and build them own sintax, i wrote a script that builds a little menu with these options and make easy for them choose what they want and don't do wrong things.

    I wanted this script runs automatically after the login in pswa... so they can't do anything that isn't provided.

    I tried use the startupscript in PSSessionConfiguration but i have read-host prompt in my script that waits the user for insert any menu options, the login in PSWA failed, because the startup script needs to run and finish before powershell windows was rendered to browser.

    Someone knows how can i run anything after login so that i can provide this menu for my users?

    Thanks e sorry for my bad english.

  • #27677
    Profile photo of Don Jones
    Don Jones

    You're going about this the wrong way. Even if you make your menu work, it's easy to cancel the menu and do whatever.

    The correct approach is to create a new Remoting endpoint that only contains the commands you want. PSWA has the ability to connect to a named endpoint, and so your technicians would connect to whichever one you tell them to. Remove their permissions to connect to the default endpoint.

    "Secrets of PowerShell Remoting" (Resources / eBooks menu on this site) explains custom Remoting endpoints.

  • #27681
    Profile photo of Abel Ferreira
    Abel Ferreira

    Thats not what happen... when i run the menu function manually, i can't cancel it... the close menu option run the exit command thats logoff the user from pswa.

    i'm studying this option to create a new endpoint, but still allows users to create them own syntax and they can do more than just reset users passwords in office 365 case. With my script the reset is easy and controlled.

You must be logged in to reply to this topic.