Open and run PowerShell script from excel vba

XL_rules

New Member
Joined
Jun 16, 2019
Messages
4
I use Google Drive for desktop a lot to download a bunch of .xlsm files. They are placed in various folders on my G:\ drive (created when Google Drive for desktop was installed.) The folder names include the date they were created (eg Folder1 - 2022-10-25; Folder2 - 2022-10-17, etc...) Hence, the folder names change with each version of the files saved on the G:\ drive.

I want to learn how to open PowerShell and run this command: get-childitem "G:\Folder1 - 2022-10-25" | unblock-file from Excel VBA? Running this command will unblock files downloaded from the internet that have been blocked for security.

It would also be nice if I could automatically change the folder name in the PS command as well (as opposed to manually changing it every time I need to unblock new files.)

I appreciate any help you can offer. Thanks.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,591
Messages
6,120,428
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top