ndalmolin_13
asked on
Help moving a file from one server to another server using Powershell
Hello Powershell Experts –
I’m trying to write a powershell script that will check for the existence of a file on the local server (ServerA) and move it to another server (ServerB) if the file exists. Here is what I have:
$data = Test-Path c:\source\*.cce
if($data = "true"){
$net = New-Object -ComObject wscript.network
$net.MapNetworkDrive("K:", "\\ServerB\target", $false, "MyDomain\file_t", "p@55word")
}
Move-Item c:\source K:\
When I run the code above, I get a message stating that a drive with the name 'K' does not exist. When I open Explorer, there is a drive with the drive letter of K. What am I missing here? Also, could someone tell me what the $false is. I put it in the script because all the examples I was basing the code from had it.
Sorry for the dumb questions.
Thanks in advanced for all of your help.
Nick
I’m trying to write a powershell script that will check for the existence of a file on the local server (ServerA) and move it to another server (ServerB) if the file exists. Here is what I have:
$data = Test-Path c:\source\*.cce
if($data = "true"){
$net = New-Object -ComObject wscript.network
$net.MapNetworkDrive("K:",
}
Move-Item c:\source K:\
When I run the code above, I get a message stating that a drive with the name 'K' does not exist. When I open Explorer, there is a drive with the drive letter of K. What am I missing here? Also, could someone tell me what the $false is. I put it in the script because all the examples I was basing the code from had it.
Sorry for the dumb questions.
Thanks in advanced for all of your help.
Nick
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.