Skip to content

Optimization: Modernize Create-ImageVirtualDisk using native PowerShell cmdlets#416

Open
msancaktutan wants to merge 1 commit intocloudbase:masterfrom
msancaktutan:optimize-disk-creation
Open

Optimization: Modernize Create-ImageVirtualDisk using native PowerShell cmdlets#416
msancaktutan wants to merge 1 commit intocloudbase:masterfrom
msancaktutan:optimize-disk-creation

Conversation

@msancaktutan
Copy link

Description:
This PR optimizes the Create-ImageVirtualDisk function to improve reliability, performance, and modernization of the codebase.

Changes:

  • Replaced Regex parsing: Switched from parsing physical drive strings (which can be risky on different hardware) to using Get-DiskImage | Get-Disk for 100% accurate disk detection.
  • Removed external dependency: Replaced the legacy format.com call with the native Format-Volume PowerShell cmdlet for faster execution and better error handling.
  • Added Retry Logic: Implemented Execute-Retry during disk detection to handle potential OS delays when attaching VHDs.
  • Code Cleanup: Improved logging and resource cleanup (closing handles).

Tested on Windows Server 2016/2019/2022/2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant