Skip to content

Instantly share code, notes, and snippets.

@mgreenegit
mgreenegit / foldertovirtualmachine.psm1
Last active June 2, 2023 15:10
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}
}