One of my tasks required creating ISO images from the list of files. I found this gist (according to author the code is in the public domain).
My company uses Powershell 6.2.2 only and that's the fact I have to deal with. Problem is that code works perfectly in Powershell 5.1 but it doesn't in Powershell 6.2.2! It gives me following error:
Add-Type : A parameter cannot be found that matches parameter name 'CompilerParameters'.
At E:\work\MSPV\New_ISOfile.ps1:19 char:11
+ Add-Type -CompilerParameters $cp -TypeDefinition @"
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-Type], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.AddTypeCommand
Unable to find type [My.FileUtil].
At E:\work\MSPV\New_ISOfile.ps1:52 char:2
+ [My.FileUtil]::WriteIStreamToFile($istream, $fileName)
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (My.FileUtil:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
The only thing I found out is that according the MS docs, in Powershell 6.x there's no such parameter as '-CompilerParameters' for Add-Type cmdlet, but there is one in Powershell 5 (5.1 namely). Tried replace it with '-CompilerOptions' but that didn't help. Same error.
Is there any way to make it work on Powershell 6.2?
Actually The call is gone in PS 6+, As in the docs
-CompilerParameters
has been replaced with-CompilerOptions
and it takes string params.you have to call it directly as the following
If you are coming from
function New-IsoFile
here is the full code