how to run powershell script through excel VBA

Question:

I am trying to use an Excel VBA macro to launch a PowerShell script if a certain condition is met. I’m not getting any errors in the code when it runs and I am able to manually run the PowerShell script from the Windows Explorer window without errors. However, when I execute the below VBA code, the PowerShell does not run and I am not sure why.

I can’t tell if something in the VBA code is wrong because I’m not getting any run time errors but the PowerShell script is not actually running

UPDATE: with the extra quotes I am able to see the error message now that’s popping up in the cmd window but it is still having issues with the space even with the extra quotes. I have moved my script to a different file path that doesn’t have spaces but I now seeing errors that running scripts are disabled. This seems like it is no longer a code based problem. thank you all!

Answer:

If your file path has spaces you need to put quotes around it.

Source:

how to run powershell script through excel VBA by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply