How Do I set up an enduser to automatically run Powershell as Admin?

Welcome Forums General PowerShell Q&A How Do I set up an enduser to automatically run Powershell as Admin?

This topic contains 7 replies, has 5 voices, and was last updated by

 
Participant
3 months, 1 week ago.

  • Author
    Posts
  • #105938

    Participant
    Points: 109
    Rank: Participant

    I have prepared a PS script which is ready to be "moved into production" for one of my endusers.
    As with these matters, I have obtained Admin privileges for a specific UserID in order that the enduser can run Powershell.
    Upon Logon, the user is presented with a "bare bones" Windows 7 Desktop and my intent is to have him/her simply click something from the Desktop and it automatically goes into running my PS script, which is kept in the enduser's Documents directory.
    1 – Is this possible from a Windows 7 standpoint? If so, how?
    2 – If not, the next best option (to me, as of now) is to instruct the enduser to Run as administrator, Powershell.
    When this is the case, the UserID defaults to a
    C:\Windows\System32 >
    prompt, and now I have to instruct the enduser to type a command or 2 to position to his Documents folder.
    What's the best approach to position to his/her Documents without typing anything more than a filename.(exe, ps1, or bat)?
    Would be grateful for any advice or tips.

  • #105950

    Participant
    Points: 7
    Rank: Member

    Are you thinking of running the Powershell script as an executable file? You would need a tool to convert the .ps1 file to an EXE, however they're kinda flaky. PS2EXE is one that comes to mind. You will need to have a certain version of .Net Framework and Powershell.

    Another option is to have a profile that's loaded every time the user opens Powershell. Create a Profile script that sets the working directory in the console . Save your script in the user's Powershell Modules directory (C:\Users\username\Documents\WindowsPowerShell\Modules) and set it as the default working directory in the Profile script.

    • #105953

      Participant
      Points: 109
      Rank: Participant

      Many thanks Mr. Burns, much appreciated.

  • #105955

    Participant
    Points: 144
    Helping Hand
    Rank: Participant

    Regardless of the fact that I think that there should be another way than giving administrative rights to someone not deserving them there is a way you could try. You could set up a scheduled task with the proper command line for your powershell script and the setting "run with highest privileges" and place a shortcut to this scheduled task to the desktop or the start menu. This would allow the user to run this script elevated without the UAC request to elevate.

    • #105997

      Participant
      Points: 109
      Rank: Participant

      Thank you Mr Olaf Soyk.
      I couldn't agree with you more ... unfortunately the "real world" factor is in play for my target user environment.
      The office is a staff of 7 persons overseeing a low-end manufacturing (food processing) with another 30 to 100 staff depending on the season. The application is actually quite sensitive – payroll. But alas, there is not even an IT support person for this staff of 7 persons. I am the "goto guy" when anything as simple as a failed logon happens. And I am not physically there 80% of the time.
      In any case, your suggestion is the one I will pursue and implement.
      My sincerest thanks for your advice.

  • #105964

    Participant
    Points: 213
    Helping Hand
    Rank: Participant

    Unless you are hiding all this console stuff from the user, all the user needs to do is select the console window and CRTL Break out of the script and now they are admin to do whatever they choose, set whatever they choose before they'd need to run it again to finalize what you were after for your use case.

    Olaf's suggestion is more prudent

    I would even go as far as to avoid the desktop thing all together. Just let TS fire this off at logon.

  • #105977

    Participant
    Points: 160
    Helping Hand
    Rank: Participant
    Set-Location -Path ([environment]::GetFolderPath("mydocuments"))
    
    • #106000

      Participant
      Points: 109
      Rank: Participant

      Thanks Mr Simmers, much appreciated.

The topic ‘How Do I set up an enduser to automatically run Powershell as Admin?’ is closed to new replies.