Last active
June 2, 2023 15:10
-
-
Save mgreenegit/deed6b15f039c6a849c0 to your computer and use it in GitHub Desktop.
Copy the contents of a folder in to a virtual machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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