Hello all,
I have been testing a VBA code that will run a Powershell (.ps1) file located on my desktop. When I click on the file directly it works without issue. When I try to run it through VBA, Powershell launches and gives me this issue:
File C:\Users\drew\Desktop\showDSKTP.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: ) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
The Execution Policy at the moment is set to unrestricted, so I am not sure if it is something with Powershell, or something in the VBA code that is causing my issue.
I have been testing a VBA code that will run a Powershell (.ps1) file located on my desktop. When I click on the file directly it works without issue. When I try to run it through VBA, Powershell launches and gives me this issue:
File C:\Users\drew\Desktop\showDSKTP.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: ) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
The Execution Policy at the moment is set to unrestricted, so I am not sure if it is something with Powershell, or something in the VBA code that is causing my issue.
VBA Code:
Sub test()
'Call Powershell and run scripts
Call Shell("powershell -noexit -file ""C:\Users\drew\Desktop\showDSKTP.ps1", vbMaximizedFocus)
End Sub