Yes, if a number of conditions are met:
In that case, you can use the InflateVirtualDisk method.
$datastoreName = 'Datastore_005'
$vm = Get-VM -Name $vmName
if($vm.PowerState -ne 'PoweredOff'){
Write-Host "The VM needs to be powered off"
}
if(Get-SNapshot -VM $vm){
Write-Host "There may not be snapshots on the VM"
}
$si = Get-View ServiceInstance
$vmdkMgr = Get-View -Id $si.Content.VirtualDiskManager
$dc = Get-Datacenter -VM $vm
Get-HardDisk -VM $vm | where{$_.StorageFormat -eq 'Thin' -and $_.Filename -match $datastoreName} |
ForEach-Object -Process {
Write-Host "Inflating $($_.Name) on $($vm.Name)"
$vmdkMgr.InflateVirtualDisk($_.Filename,$dc.ExtensionData.MoRef)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference