Trying to make a .bat I can drop in a folder, when run it will unblock all the files in that folder...
@ECHO OFF
PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {get-childitem '%~dp0' | unblock-file}"
EXIT
...keeps telling me "The term 'unblock-file' is not recognized as the name of a cmdlet..." no matter how I try to format it, where am I going wrong?
I'm trying to do this so I can just copy the .bat to the folder (and NOT have to copy a .bat and .ps1) so I thought a 1-line powershell "call" was the way to go?
The unblock-file
command is available from Powershell 3.0.
Upgrade your PowerShell and script should work
Tested and working:
dir -r | unblock-file
Unblocks everything from the current directory recursively
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With