How to copy or move a file across a domain using Powershell

Follow

 

### Import Module
Import-Module JAMS

$JAMSUser = "TestUser"
$JAMSDefaultServer = "JAMSServerName"

### Define your Source files
$Source = "\\Domain1Server\Folder\*"

### Get credentials from a JAMS user to map the drive
[System.Management.Automation.PSCredential]$cred = Get-JAMSCredential $JAMSUser

### Set your destination
$Destination = "J:\"

### Map your drive using secure credentials
New-PSDrive -Name J -root \\Domain2Server\Folder -PSprovider FileSystem -credential $cred

### Perform your move or copy 
Move-Item -Path $Source -Destination $Destination -verbose
#Copy-Item -Path $Source -Destination $Destination -verbose

 

 

 

Have more questions? Submit a request

Comments