Hello, I ran into a strange problem when I was using PowerShell 5.1

%3CLINGO-SUB%20id%3D%22lingo-sub-3290015%22%20slang%3D%22zh-CN%22%3EHello%2C%20I%20ran%20into%20a%20strange%20problem%20when%20I%20was%20using%20PowerShell%205.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3290015%22%20slang%3D%22zh-CN%22%3E%3CP%3EI%20want%20to%20use%20the%20following%20command%3A%3C%2FP%3E%3CP%3ECall%20PowerShell%20script%20through%20CMD%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EC%3A%5C%5CWindows%5C%5CSystem32%5C%5CWindowsPowerShell%5C%5Cv1.0%5C%5Cpowershell.exe%20%2Fc%20D%3A%5C%5Ctest.ps1%20-test%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20I%20ran%20into%20a%20very%20strange%20problem.%20I%20have%20two%20windows%20hosts%20I%20run%20it%20on%20my%20test%20machine%20and%20it%20takes%20only%20a%20few%20hundred%20milliseconds%2C%20but%20I%20deploy%20it%20on%20another%20host%20with%20the%20same%20configuration%20and%20performance%2C%20and%20it%20takes%20three%20seconds%20to%20%20execute!!!!!!!!%3C%2FP%3E%3CP%3EAs%20far%20as%20I%20can%20see%2C%20on%20windows%20where%20I%20deploy%20the%20service%2C%20every%20time%20I%20start%20PowerShell%2C%20the%20CPU%20will%20be%2080-100%25.%3C%2FP%3E%3CP%3EMy%20system%20is%20windows%20server%202016.%3C%2FP%3E%3CP%3EMy%20PowerShell%20version%20is%205.1%3C%2FP%3E%3CP%3EI%20hope%20the%20great%20God%20can%20answer.%20Thank%20you%20very%20much.%3C%2FP%3E%3CP%3EGod%20is%20with%20you.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3290015%22%20slang%3D%22zh-CN%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

I want to use the following command:

Call PowerShell script through CMD

 

C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe /c D:\\test.ps1 -test

 

 But I ran into a very strange problem. I have two windows hosts I run it on my test machine and it takes only a few hundred milliseconds, but I deploy it on another host with the same configuration and performance, and it takes three seconds to execute!!!!!!!!

As far as I can see, on windows where I deploy the service, every time I start PowerShell, the CPU will be 80-100%.

My system is windows server 2016.

My PowerShell version is 5.1

I hope the great God can answer. Thank you very much.

God is with you.

 

 

 

 

3 Replies

@hexler Ok, let's try and zoom in to the real problem ;) If you start PowerShell on the server, just start it without loading a script. How long does that take? What does the script do? And when you already have PowerShell running, it is faster if you start the script? (Should be faster because already in memory) 

Do you have some more information regarding your issue?

Do you have any update for us?