在Copy-Item中集成认证信息以拷贝文件

$source = "c:\XXX.XXX"
$pw = ConvertTo-SecureString '密码' -AsPlainText -Force
$Creds = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist 'softdump\ultraman', $pw
New-PSDrive -Name P -PSProvider FileSystem -Root '\\3.242.164.147\SOE' -Credential $Creds -Persist
Copy-Item -Path $source -Destination 'P:\' -Recurse -Force
Remove-PSDrive -Name P

 

posted @ 2015-05-11 09:30  dongdonggeorge  阅读(436)  评论(0编辑  收藏  举报