Invoke-Expression From Admin Prompt to Run Script as Non Admin RRS feed

  • Question

  • I am trying to create a PowerShell Script that runs as Administrator and Does somethings and then kicks off another PowerShell Script but I want the other PowerShell Script to run as Non Admin. I know how to Elevate Permeations using -Verb RunAs but I need to go the other way.  The reason is, the other script is going to add an even to the users Outlook Calendar and when you  create New-Object -Com Outlook.Application from an Admin PowerShell session and Outlook is open as Non Admin it fails.  You can Stop-Process -Name Outlook and it will work but that will Close Outlook for the user in the middle of what they are doing.  What I want to do is kick off another PowerShell Script to do the Outlook Tasks in a Non Admin PowerShell.

    Everything I find when searching is in relation to raising permeations but nothing about going the other way. 

    • Moved by Bill_Stewart Monday, October 2, 2017 9:51 PM Unanswerable drive-by question
    Thursday, August 24, 2017 7:00 PM

All replies

  • None of that makes any sense.  Any iuser can open Outlook with PowerShell.  Opening PowerShell as an Admin will not run it as a user it will run in th admin account and mail profile.

    Outlook will not run correctly if you are trying to force it  into a hidden shell.

    It would be better if you explained what the purpose of this is.  Due to the design of Windows what you are asking is not possible.

    To run Outlook from any user session just do this:

    $ol = New-Object -Com Outlook.Application

    This will attach to the current Outlook session.

    To leave Outlook running just exit PowerShell.

    You  cannot start a process in another users session form an elevated admin shell.

    What are "permeations"?


    • Edited by jrv Thursday, August 24, 2017 7:52 PM
    Thursday, August 24, 2017 7:51 PM