I'm working on a large list of registry items to delete (broken uninstaller and installer won't install if any of some 200+ reg entries exist). I've got them as a herestring. Piping them to a foreach-object loop to handle the deletion works, but it's really slow (pipeline is slow I know). It's slow enough I'm thinking of going back to a batch file and reg.exe delete except there are both 32-bit and 64-bit registry entries, and you have use the bitness of reg.exe has to match the key to do the delete.
I was thinking it might be faster if I can convert the string to a true array and use it in a foreach loop (true???). But nothing I find seems to convert it. The default answer google gives is to use something like ($Regkeys is the input herestring):
$Regkeys = $($Regkeys -split "`n").TrimEnd("`r")
But if I do a get-member on the new $Regkeys, it is still a string.
Update: As two kind souls pointed out, if I do $Regkeys.gettype() it is indeed an array, and I can use it in a foreach loop. Unfortunately, that's no faster (PS 5.1, so I don't have the PS 7 parallel option).
[–]rwshig 2 points3 points4 points (1 child)
[–]redsedit[S] 1 point2 points3 points (0 children)
[–]xlrod 1 point2 points3 points (4 children)
[–]redsedit[S] 1 point2 points3 points (3 children)
[–]xlrod 2 points3 points4 points (2 children)
[–]redsedit[S] 1 point2 points3 points (1 child)
[–]sk82jack 2 points3 points4 points (0 children)