在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

 

你可能感兴趣的:(copy)