how to copy a folder and its content on a mapped drive using powershell
hi all
having problem in copying recent folder local remote pc using net use. here code
$local = "c:\projects\deployments\" ;
$path = "\\myip\deployments";
$recent = get-childitem -path $local | sort-object -property lastwritetime | select-object -last 1
net use b: $path /user:username password
copy-item -path $recent -destination "b:\" -recurse -force
above script works perfect if take out $recent line , if specify exact folder name in $local
e.g $local = "c:\projects\deployments\2014-10-13" ;
getting strange error when run script, directory running script tries in folder recent folder needs copying.
having problem in copying recent folder local remote pc using net use. here code
$local = "c:\projects\deployments\" ;
$path = "\\myip\deployments";
$recent = get-childitem -path $local | sort-object -property lastwritetime | select-object -last 1
net use b: $path /user:username password
copy-item -path $recent -destination "b:\" -recurse -force
above script works perfect if take out $recent line , if specify exact folder name in $local
e.g $local = "c:\projects\deployments\2014-10-13" ;
getting strange error when run script, directory running script tries in folder recent folder needs copying.
i sorted out, have write
copy-item -path $recent.fullname
Windows Server > Windows PowerShell
Comments
Post a Comment