Quantcast
Channel: Azure Virtual Machines forum
Viewing all articles
Browse latest Browse all 12545

using powershell to copy a folder to a vm

$
0
0

Previously while using the amazon cloud I have used New-PsDrive and copy-item to move folders to virtual machines. But while attempting this using a credential I get a could not map network drive error. Is there something more fundamental that I do not understand with the vm drives, or should this work and it is just my error.

function CopyFolders( )
{
 $credential = CreateCredentials;
 $relDir = Split-Path $source -Leaf
 new-psdrive -name remoteDrive -psProvider FileSystem -Root "xxxx" -Credential $credential 
 if ( Test-Path "xxxx" )
 {
    "removing ... xxxx"
    Remove-Item -Path "remoteDrive:$relDir" -Recurse -Force 
 }
 "copying ..."
 Copy-Item -Path $source -Destination "remoteDrive:" -Recurse
 Remove-PSDrive remoteDrive
}


Viewing all articles
Browse latest Browse all 12545

Trending Articles