Skip to content

Instantly share code, notes, and snippets.

@jcpowermac
Created December 11, 2013 18:49
Show Gist options
  • Select an option

  • Save jcpowermac/7916164 to your computer and use it in GitHub Desktop.

Select an option

Save jcpowermac/7916164 to your computer and use it in GitHub Desktop.
Copy gzip files from ESXi
Add-PSSnapin VMware.VimAutomation.Core
$basedir = "C:\Desktop\ESXTOP-04032012-130000\";
if( !(Test-Path $basedir) ){
New-Item -Type Directory $basedir
}
$datastores = Get-Datastore -VMHost (get-vmhost) | Where {$_.Name.Contains("-local") }
foreach( $ds in $datastores ) {
$newdir = $basedir + $ds.Name;
if( !(Test-Path $newdir) ){
New-Item -Type Directory $newdir
}
$item = $ds.DatastoreBrowserPath + "\*.gz";
Copy-DatastoreItem -Item $item -Destination $newdir
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment