I have a lot of powershell modules that I have been working on, and I have been tasked with distributing them as a single executable. I made a batch script to run my powershell stuff and I am using that batch script as the target of a WinRAR SFX executable.
The issue is that when I run the script through the batch file, everything works fine, but when I run I run it through the executable, the script has errors. These errors are not "Failure" errors, but exceptions thrown by my own powershell script. My powershell code is running differently when it is run through batch or through WinRAR SFX. Has anyone experienced this and know how to fix it?
If you want more information on the type of error my powershell is throwing, in my script I am doing a breadth first search on a small portion of the registry. When I run it with the batch script wrapper, it runs in ~30 seconds with no errors. When I run it with the WinRAR SFX Executable, it throws this error:
Cannot convert argument "index" with value "CLSID", for "GetValue" to
type "System.Int64": Cannot convert value "CLSI" to type "System.Int64".
Error: "Input string was not in a correct format.""At
C:\Users\Administrator\AppData\Local\Temp\RarSFX0\myscript.ps1:270
char:33
+ elseif ($key.getValue("CLSID") -new $null {
+
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentCovnersionInvalidCastArgument
After checking the types of all of the objects I am examining, at some point my registry key object becomes an array of registry key objects in the WinRAR version but not the batch version. Any ideas?