I have a very strange thing happening.
If i run powershell.exe, then in the window type this command :
Measure-Command {Get-ADPrincipalGroupMembership abc00 | select "name" | out-gridview }
the command is super fast and takes around 2 seconds.
Now if i run the exact same thing from a batch file (which contains a simple CHOICE menu) like this:
powershell.exe -command "Measure-Command {Get-ADPrincipalGroupMembership abc00 | select "name" | out-gridview}
It takes a whooping 15 seconds, making the command very heavy and annoying to use.
Why is it so slow? Could it be the CHOICE command or something? Because when i run it in an empty test.bat it's super fast...:
powershell.exe -command "Measure-Command {Get-ADPrincipalGroupMembership abc00 | select "name" | out-gridview}
P.S.: All the other commands in my batch file are fast except the powershell ones.
Thank you very much for your time and help as always.
UPDATE : I have tried to remove the choice menu entierly and replace it with a set /p menu and it still takes forever to load...What a strange problem.
-NoProfileor short-NoPafterpowershell.exe -NoPand use Powershell without a temporary vbs file to elevate. See my answer.