Skip to content

Instantly share code, notes, and snippets.

@mgreenegit
Last active June 2, 2023 15:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgreenegit/deed6b15f039c6a849c0 to your computer and use it in GitHub Desktop.
Save mgreenegit/deed6b15f039c6a849c0 to your computer and use it in GitHub Desktop.
Copy the contents of a folder in to a virtual machine
function copy-foldertovirtualmachine {
param(
[parameter (mandatory = $true, valuefrompipeline = $true)]
[string]$VMName,
[string]$Folder = '.\'
)
foreach ($File in (Get-ChildItem $Folder -recurse | ? Mode -ne 'd-----')){
Copy-VMFile -VM (Get-VM $VMName) -SourcePath $file.fullname -DestinationPath $file.fullname -FileSource Host -CreateFullPath -Force}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment