Skip to content

Instantly share code, notes, and snippets.

@keyrage
Created November 6, 2017 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keyrage/1c684cab74cb113eaea8f05d3ca64514 to your computer and use it in GitHub Desktop.
Save keyrage/1c684cab74cb113eaea8f05d3ca64514 to your computer and use it in GitHub Desktop.
####Mount an ISO as a drive in Windows
powershell_script 'Mount ISO' do
code <<-EOH
Mount-DiskImage -ImagePath "<<PATH TO ISO>>"
if ($? -eq $True)
{
echo "ISO was mounted Successfully." > #{ENV[TEMP]}\\ISO_Mounted_Successfully.txt
exit 0;
}
if ($? -eq $False)
{
echo "ISO Failed to be mounted." > #{ENV[TEMP]}\\ISO_Mount_Failed.txt
exit 2;
}
EOH
action :run
guard_interpreter :powershell_script
not_if "((gwmi -Class Win32_LogicalDisk | Where-Object {$_.VolumeName -eq \"<<VOLUME NAME>>\"}).VolumeName -eq \"<<VOLUME NAME>>\")"
end
#### DISMOUNT AN ISO
powershell_script 'Dismount ISO' do
code <<-EOH
Dismount-DiskImage -ImagePath "<<PATH TO ISO>>"
EOH
action :run
guard_interpreter :powershell_script
only_if "((gwmi -Class Win32_LogicalDisk | Where-Object {$_.VolumeName -eq \"<<VOLUME NAME>>\"}).VolumeName -eq \"<<VOLUME NAME>>\")"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment