
Powershell 스크립트의 일부로 ISO 디스크 이미지에서 파일을 읽고 싶습니다. 이는 자동화된 프로세스이고 디스크가 일시적으로만 열려 있기 때문에 드라이브 문자와 같은 불필요한 리소스를 할당하지 않는 것이 좋습니다.
답변1
다음은 드라이브 문자를 할당하지 않고 ISO에서 읽는 간단한 방법입니다(* 아래 참조).
$DiskImage = Mount-DiskImage -ImagePath $ISOPath -StorageType ISO -NoDriveLetter -PassThru
New-PSDrive -Name ISOFile -PSProvider FileSystem -Root (Get-Volume -DiskImage $DiskImage).UniqueId
Push-Location ISOFile:
# read files with the usual filesystem commands
Pop-Location
Remove-PSDrive ISOFile
Dismount-DiskImage -DevicePath $DiskImage.DevicePath
*에서 생성된 드라이브는 New-PSDrive
실제 Windows 드라이브가 아니며 PowerShell 외부 또는 New-PSDrive
실행된 Powershell 기능 외부에서도 표시되지 않습니다. Remove-PSDrive
한 범위에서 위의 내용을 여러 번 사용하지 않는 경우 호출이 필요하지 않을 수도 있습니다 .