Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

powershell copy-item specify credentials

$Source = "C:Downloadsmyfile.txt"
$Dest   = "10.149.12.162c$skumar"
$Username = "administrator"
$Password = ConvertTo-SecureString "Complex_Passw0rd" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential($Username, $Password)

New-PSDrive -Name J -PSProvider FileSystem -Root $Dest -Credential $mycreds -Persist
Copy-Item -Path $Source -Destination "J:myfile.txt"
 
PREVIOUS NEXT
Tagged: #powershell #credentials
ADD COMMENT
Topic
Name
5+1 =