#Running commands in powershell

17 messages · Page 1 of 1 (latest)

glass iris
#

Hello, I have been running powershell commands through cmd
For example: cmd /C powershell Get-AppPackage
But I have noticed that it takes a lot more time to execute as compared to running the command in powershell itself
So I am wondering if there is a way to run commands in powershell directly to reduce the time it takes to execute

exotic imp
#

PowerShell Start-Process -FilePath <path-to-executable>

glass iris
#

I want to run powershell commands though just like in example

placid current
#

Start-Process is a powershell command

#

just replace it with Get-AppPackage for your example

glass iris
#

It does take a few seconds before executing the command

#

This could be a problem with windows trying to launch powershell maybe

placid current
#

probably yeah

#

if you spawn a powershell terminal it's pretty slow (for me) too

glass iris
#

That's why I was thinking why can't we run the commands directly in powershell(through the code)

placid current
#

yeah, but it's powershell itself taking so long to start, not the shell (what i meant in my message) or cmd.exe (from your initial message)

#

though tbf, cmd.exe tends to be slower to start powershell then starting powershell directly

#

but since powershell is so slow it's probably not noticable

#

you could also try the -NoProfile flag to check if your user profile slows it down (mine slows it down quite a lot because i run a few scripts)

glass iris
#

Tried that didn't help me much

#

Although I tried using ngen on powershell assemblies that did help me speed up

#

But I can't just use ngen in the user's desktop so that's not a viable solution in my case