I found a couple of answers here which break at the space between Powershell and scripts.
Sub Test()
Dim scriptlocation As String
scriptlocation = "C:\REDACTED\Powershell Scripts\ConmonInfoFinder-V7.ps1"
Dim x As Variant
x = Shell("""POWERSHELL.exe"" ""C:\REDACTED\Powershell Scripts\ConmonInfoFinder-V7.ps1""", vbNormalFocus)
End Sub
Or
Sub Test()
Dim scriptlocation As String
scriptlocation = "C:\REDACTED\Powershell Scripts\Powershell Scripts\ConmonInfoFinder-V7.ps1"
strCommand = "Powershell -File" & scriptlocation
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)
End Sub
Both of these open Powershell but they won't run the script. The first one dies at the space in between Powershell Scripts and the second one flashes the windows with no error, but isn't running the script.
EDIT: I made some changes.
Sub Test()
Dim scriptlocation As String
scriptlocation = "C:\REDACTED\Powershell Scripts\trial.ps1"
strCommand = "Powershell -NoExit -File """ & scriptlocation & """"
Set WshShell = CreateObject("WScript.Shell")
Set WshShellExec = WshShell.Exec(strCommand)
The window still flashes up and then goes away. I made a sample script of just Hello World to make sure it wasn't anything weird in my script and I have the same result.
EDIT:
It is now fixed.
Sub Test2()
Dim scriptlocation As String
scriptlocation = "C:\REDACTED\Powershell Scripts\ConmonInfoFinder-V7.ps1"
strCommand = "Powershell -ExecutionPolicy Bypass -NoExit -File """ & scriptlocation & """"
Set WshShell = CreateObject("WScript.Shell")
WshShell.Exec (strCommand)
End Sub