I have a strange problem when launching Powershell commands from VBS.
Sometimes, it works and sometimes, not. It occurs on startup scripts or GPOs (SYSTEM and USER permissions)
I don't see the issue when launching ps1 files instead, only with -command. The powershell opens (in taskmgr), doesn't exit, does nothing and there's a memory leak.
Here's two example of the code, it may stuck on any powershell -command. Tried -NoProfile, -NonInteractive, Exit-PSSession, Exit, etc.
objShell.run("powershell -NoProfile -NoLogo -NonInteractive -command ""& {Set-ExecutionPolicy unrestricted; import-module 'C:\Program Files\Microsoft Application Virtualization\Client\Appvclient'}""", 0, True)
objShell.run "powershell -command ""& { add-appxpackage -registerbyfamilyname -MainPackage Microsoft.Windows.Photos_8wekyb3d8bbwe }""",0,true
- OS: Windows 10 Education 20H2
- Powershell: 5.1.19041.1320