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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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