VMware Cloud Community
AnonymousDefaul
Enthusiast
Enthusiast

What is the correct way to run powershell scripts during installation?

I need to run a few PowerShell scripts during installation, but I'm having problems running PowerShell from a runProgram action.


If I create a runProgram action that runs PowerShell directory I see an error dialog with contents like this,


Problem signature:
Problem Event Name: PowerShell
NameOfExe: powershell.exe
FileVersionOfSystemManagementAutomation: 6.1.7601.17514
InnermostExceptionType: System.ComponentModel.Win32Exception
OutermostExceptionType: System.Management.Automation.Host.Host
DeepestPowerShellFrame: erShell.ConsoleControl.GetActiveScreenBufferHandle
DeepestFrame: erShell.ConsoleControl.GetActiveScreenBufferHandle
ThreadName: Consol.. main thread
OS Version: 6.1.7601.2.1.0.272.7
Locale ID: 2057

To work around this I have tried running PowerShell by running it through cmd.exe like this,


<runProgram>
    <program>cmd.exe</program>
    <programArguments>/C ' powershell.exe -File &quot;<path to script>&quot;' </programArguments>
</runProgram>

Does anyone know what might cause the error and what the ' correct'  way to run PowerShell scripts is?
Running powershell through cmd seems to work, but I would like to understand why I can't run it directly.


Thanks,


Matthew

Labels (1)
0 Kudos
3 Replies
AnonymousDefaul
Enthusiast
Enthusiast

In which version of Windows are you testing it? Have you modified the <requestedExecutionLevel> in your project?

0 Kudos
HedleyPhillips
Contributor
Contributor

Hi,

did you resolve this issue?

I'm also trying to run a Powershell script and am not getting any output and the test run hangs at creating a shortcut link.

I've added requestedExecutionLevel but it hasn't made any difference.

Thanks.

0 Kudos
michieldhont_
Hot Shot
Hot Shot

Hi @HedleyPhillips,

Could you run the installer with the --debugtrace and contact us in private support?

 

.\installer.exe --debugtrace debug.txt

 

Regards,

Michiel

0 Kudos