This topic contains 7 replies, has 5 voices, and was last updated by
August 5, 2018 at 9:18 am #105938
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
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.
August 5, 2018 at 4:16 pm #105950ParticipantPoints: 7Rank: 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.
August 5, 2018 at 5:05 pm #105953
Many thanks Mr. Burns, much appreciated.
August 5, 2018 at 6:49 pm #105955ParticipantPoints: 144Rank: 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.
August 6, 2018 at 4:29 pm #105997
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.
August 5, 2018 at 11:02 pm #105964ParticipantPoints: 213Rank: 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.
August 6, 2018 at 12:48 pm #105977ParticipantPoints: 160Rank: Participant
Set-Location -Path ([environment]::GetFolderPath("mydocuments"))
August 6, 2018 at 4:31 pm #106000
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.