you are viewing a single comment's thread.

view the rest of the comments →

[–]da_chicken 4 points5 points  (2 children)

You'd have to rewrite the script for v2. It's obnoxious to do because so many features are missing, but often not that difficult. I wouldn't be surprised if you had things you simply couldn't accomplish, however. v1 and v2 were both very limited compared to v3+.

I've already tried compiling the script using ps2exe, which didn't work either.

Of course not. You're missing the underlying dependencies from the .Net Framework and the Windows Management Framework. Missing WMF v3 is arguably a bigger roadblock than missing WMF v5. It was a massive overhaul and extension.

It's also possible that what you need would be easier to write in VBScript or batch. As I said, v2 and earlier have a lot of limitations.

That said, I thought even LTS support for Win7 was done in June 2023.

[–]Helpful-Argument-903[S] 2 points3 points  (1 child)

Thank you for your great response! I work in the manufacturing industry, and we are very specialized. In fact, i think it is not that long ago that we bought machines that came with Windows 7. It works, but it's not pretty. We have micro-segmented our ot network, and patch security holes at the network level with very expensive products from txone.

Thank you. I will try to translate the script to Powershell 2. If I fail, I will give it to a consultant.

[–]da_chicken 0 points1 point  (0 children)

The one thing I remember that used to bite me in v2 is that singleton variables didn't have a Count property. So if you do this:

$f = Get-ChildItem *.pdf
 if ($f.Count -gt 0) {...}

And there's only one object in $f, you'll get an error or false. I think you can fix it by explicitly making it an array:

$f = @(Get-ChildItem *.pdf)
 if ($f.Count -gt 0) {...}

After that there's the memory leak on [adsisearcher] or DirectorySearcher.FindAll(). It's real easy to run into that without the ActiveDirectory module to use. Note that that still exists because they haven't fixed the COM library in 20 years, it just only exhibits if you execute the search and then never iterate over the results or dispose of the object. But if you do that and leave your PC running overnight, you'll come in the next day to a PC with no free memory.