Thursday, February 07, 2013

Using New-IsoFile to Put Files into an ISO

I use Hyper-V all the time and love the convenience of just attaching an ISO to get files into my VMs, because I don’t have to worry about networks or credentials.

Sometimes the files I need are not already on an ISO, and I used to use various utilities to create new ISOs, until I found New-IsoFile.

Here is how it works:

 

###

### Copy a single file into an ISO

###

dir 'E:\wheres\SharePoint2013.exe' |

New-IsoFile -Path c:\ISO\SharePoint2013.ISO -Title 'SharePoint 2013'

 

###

### Copy an entire folder into an ISO

###

dir 'E:\HoofHearted' |

New-IsoFile -Path c:\ISO\HoofHearted.ISO -Title 'HoofHearted'

 

When the command finishes, you have your new ISO file ready to be attached to VMs. Cool!

FYI – when I first ran it on Win8 I hit this error:

Add-Type : Cannot add type. The 'CompilerParameters' parameter and the 'IgnoreWarnings' parameter cannot both be specified.

At line:38 char:7

+       Add-Type -IgnoreWarnings -CompilerParameters $cp -TypeDefinition @"

+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (System.CodeDom....pilerParameters:CompilerParameters) [Add-Type], Exception

    + FullyQualifiedErrorId : COMPILERPARAMETERS_AND_IGNOREWARNINGS,Microsoft.PowerShell.Commands.AddTypeCommand

 

The fix is just to change line:38 so it looks like this:

 

      Add-Type -CompilerParameters $cp -TypeDefinition @"

 

No comments: