I understand I can use diskpart /s
to script diskpart
select vdisk file=FILE_SUPPLIED_BY_COMMAND_LIME_PARAMETER
attach vdisk readonly
compact vdisk
detach vdisk
exit
And then run it with:
diskpart /s scriptname.txt /t 15
But can I add command lime parameters to diskpart? Eg so I can specify the VHDX file by the command line?
If that's not possible, faking command line parameters with a Powershell wrapper to make the diskpart script dynamically might also be an option.
You can pipe to
diskpart
. I'd read the file and replace your values when the file contents are retrieved:You can use a string and bypass reading a file:
If you want to use parameters, then you will need a function or script block. Using a script block:
Using a function: