TIP: Using PowerShell in Windows 7

Put simple Tips and Tricks that are not entire Tutorials in this forum
Posts: 172
Joined: 27 Oct 2013, 08:32

TIP: Using PowerShell in Windows 7

18 Oct 2016, 17:14

I often find that it's just quicker and easier to wrap a PowerShell 'one-liner' code block in AHK than try to do the same using nothing but AHK. (I accept that I'm a rubbish and lazy AHK programmer. :) )

Here's another 'gotcha' I ran into that I thought I would document to save others from pulling their hair out.

Be aware that the default version of PowerShell in Windows 7 is v2... and thus has no support for many cmdlets available in either PowerShell v3, v4 or v5.

For example, it took me ages to work out why the following 'Unblocker' script worked perfectly well in Windows 10 but didn't work at all in Windows 7:


The answer turned out to be that the default version of PowerShell built-in to Windows 7, i.e. v2.0, doesn't support Get-ChildItem -Path '%SourceVar%' -Recurse | Unblock-File. Eventually I found out that I needed to install PowerShell v3 for it to work.

So... if your PowerShell code wrapped in AHK doesn't work, consider building in a check for the version of PowerShell on the target device.

Hope this helps...

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 0 guests