I need your help with a script that i am building.I need it to:` To find a VM and see if it is turned off or on. If it is off then turn it on and copy a folder with the content to replace the old folder in the VM machine.
$vmName = 'Target' $folderName = 'C:\Folder'
Get-VM -Name $vmName | where{$_.PowerState -ne 'PoweredOn'} | Start-VM -Confirm:$false sleep 30
Copy-VMGuestFile -LocalToGuest -Source $folderName -Destination $folderName -Confirm:$false
My problem is that the folder and its content is copy to the destination but it will not replace the folder and its content from the destination VM.
Regrades,
Michel Vaillancourt