如何在PowerShell中调用应用程序快捷方式并传递参数

如何在PowerShell中调用应用程序快捷方式并传递参数,powershell,administrator,elevated-privileges,desktop-shortcut,Powershell,Administrator,Elevated Privileges,Desktop Shortcut,我需要从一个不是管理员的帐户调用MSTEST.exe,并将参数作为“提升的/admin”传递,该帐户不能为。我为MSTest.exe创建了一条名为“MSTest_highted.lnk”的捷径。我可以调用它并通过命令行传递参数,一切正常,请参见以下内容: REM Set up test executable variables REM SET MSTEST_EXECUTABLE="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common

我需要从一个不是管理员的帐户调用MSTEST.exe,并将参数作为“提升的/admin”传递,该帐户不能为。我为MSTest.exe创建了一条名为“MSTest_highted.lnk”的捷径。我可以调用它并通过命令行传递参数,一切正常,请参见以下内容:

REM Set up test executable variables
REM SET MSTEST_EXECUTABLE="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe"
SET MSTEST_EXECUTABLE="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest_Elevated.lnk"
SET NUNIT_EXECUTABLE="C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console.exe"

CD %WORKSPACE%

SET WORKSPACE_TEST_RESULTS=%WORKSPACE%\TestResults_Integration

REM Create test result folder
IF NOT EXIST "%WORKSPACE_TEST_RESULTS%\" ECHO "Creating %WORKSPACE_TEST_RESULTS%"
IF EXIST "%WORKSPACE_TEST_RESULTS%\" ECHO "%WORKSPACE_TEST_RESULTS% EXISTS"
IF NOT EXIST "%WORKSPACE_TEST_RESULTS%\" md "%WORKSPACE_TEST_RESULTS%"

REM Run the tests
%MSTEST_EXECUTABLE% /resultsfile:"MyServiceTestsResults.trx" /testcontainer:"MyService\Test\Unit\MyServiceTests\bin\Release\MyServiceTests.dll" /nologo 

REM Clear up test executable variables
SET MSTEST_EXECUTABLE=
SET NUNIT_EXECUTABLE=
但是,我的解决方案无法使用命令行,需要使用PowerShell。我可以像这样从PowerShell调用MSTEST,但不能作为管理员。如果我尝试调用提升的快捷方式,它也会失败

Execute-Command -commandTitle "MSTest" -commandPath "`"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe`"" -commandArguments "/xml:`"MyServiceTestsResults.trx`" `"MyService\Test\Unit\MyServiceTests\bin\Release\MyServiceTests.dll`" /nologo ";
快捷方式似乎运行正常,但未调用MSTEST。所以

是否有一种方法可以通过提升的快捷方式调用MSTest.exe,在PowerShell中使用参数调用,就像我从BAT文件调用它一样