Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

powershell with mapped drive not working but works with local drive

$
0
0

If I run this script (backup_script_loop.ps1):

$computerlist = import-csv C:\Users\USER\desktop\PCLIST.csv

foreach ($PC in $PSLIST)

{

     Invoke-Command -ComputerName $PC.PC -ScriptBlock{C:\Installers\Backup_Copy}

}

 

I get this error

PS C:\Users\USER\Desktop> C:\Users\USER\Desktop\backup_script_loop.ps1

0 File(s) copied

Invalid drive specification

 

 

Contents of backup_Copy.cmd:

@echo off

xcopy c:\BACKUP.bak \\COMPUTER\backups

 

However, if I run the backup_copy command, locally it works.  If I also change the drive letter to a local hard drive (xcopy c:\BACKUP.bak e:\backups) then the remote powershell command works as well. 

How do I get the mapped drive command to work while being called from powershell?

 

Thanks in advance


Viewing all articles
Browse latest Browse all 6937

Trending Articles