any idea how I can add +10GB to existing "hard disk 1" without having to know the current capacity?
Try like this
ForEach-Object -Process {
Set-HardDisk -HardDisk $_ -CapacityGB (10 + $_.CapacityGB) -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc
when i tried this it only made a 1GB to 10GB instead of 11GB
this is my command
Get-VM -Name test | Get-HardDisk -Name 'Hard disk 2' | Set-HardDisk -CapacityGB (10 + $_.CApacitygb)
That will not work, you can only reference the pipeline object ($_) in a script block.
See my previous answer.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank Luc. That works.
however when i add resizeguestpartition to it. seems to have frozen up
Did you see the warning on the help entry for the Set-Harddisk cmdlet?
"Note: This functionality is deprecated and is not functional on the currently supported guest operating systems. Resizing guest disks works only on Windows XP Service Pack 3 and Red Hat Enterprise Linux 5. "
That might be causing the hang.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I got this working only on the first VM on the servers.txt list when expanding the E drive. but failedon the second.
any idea whats going on?
If I go back and manually run
invoke-command -computername server2 -scriptblock $scriptblock -credential $creds
it works fine
You get that error when the used space on the partition is higher than the value you pass on the Size parameter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference