复制远程服务器上的文件 [英] Copy files on remote servers
问题描述
大家好
以下是我尝试执行的代码,用于将多个文件从一个文件夹复制到远程服务器上的其他文件夹但我收到此错误
PS C:\ Windows> D:\ScriptRepo \Smart_Backup_Create folders_by_Date.ps1
在'D:\ScriptRepo \Smart_Backup_Create folders_by_Date.ps1:5'上点击线断点
[DBG]:PS C:\ Windows>> ;
\\ $ ComputerName \ $ DriveLetter $ \BMCSoftware\BMCPortalKit\webserver\tools\apache-openssl\logs:
'\\ $ ComputerName \\ \\ $ DriveLetter $ \BMCSoftware \ BMCPortalKit \webserver \tools \ apache-openssl \ logs'不会被识别为cmdlet,函数,脚本文件或可运行程序的名称。检查名称的
拼写,或者如果包含路径,请验证路径是否正确,然后重试。
在D:\ ScriptRepo \Smart_Backup_Create folders_by_Date.ps1:5 char:12
+ $ SrcPath = \\ $ ComputerName \ $ DriveLetter $ \BMCSoftware \BMCPortalKit \webserver \\ \\工具...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo:ObjectNotFound :( \\ $ ComputerName ... he-openssl\logs:String)[],CommandNotFoundException
+ FullyQualifiedErrorId:CommandNotFoundException
[DBG]:PS C:\ Windows>> ;
\\ $ ComputerName \ $ DriveLetter $ \Log_Backup _ $((Get-Date).ToString('yyyy-MM-dd')):术语'\\ $ ComputerName \ $ DriveLetter $ \Log_Backup _ $((Get-Date).ToString('yyyy-MM-dd'))'未被识别为
cmdlet,函数,脚本文件或可运行程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。
在D:\ ScriptRepo \Smart_Backup_Create folders_by_Date.ps1:6 char:13
+ $ DestPath = \\ $ ComputerName \ $ DriveLetter $ \Log_Backup _ $((Get-Date) .ToString('yyyy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo:ObjectNotFound:(\\ $ ComputerName ... ('yyyy-MM-dd')):String)[],CommandNotFoundException
+ FullyQualifiedErrorId:CommandNotFoundException
[DBG]:PS C:\ Windows>>
目录:\\USDC1-BEMAPDC01 \ $ $
模式LastWriteTime长度名称
---- ----- -------- ------ ----
d ---- 8/14/2017 5:35 AM Log_Backup_2017-08-14
[DBG]:PS C:\ Windows>>
复制项:无法找到路径'D:\BMCSoftware \ BMMortalKit \webserver \ tools \apache-openssl \logs',因为它不存在。
在D:\ ScriptRepo \Smart_Backup_Create folders_by_Date.ps1:8 char:1
+ Copy-Item -Recurse -Filter *。* -path $ SrcPath -destination $ DestPath -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo:ObjectNotFound :( D:\BMCSoftware \ ... ...-openssl \\ \\ logs:String)[Copy-Item],ItemNotFoundException
+ FullyQualifiedErrorId:PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
请让我知道我在哪里做错了。源文件夹和目标文件夹都在同一台服务器上
我尝试过:
$ ComputerName =ServerName
$ DriveLetter =D
$ CreateFolderPath =Log_Backup _ $((Get-Date).ToString('yyyy- MM-dd'))
$ SrcPath = \\ $ ComputerName \ $ DriveLetter $ \BMCSoftware \ BMMortalKit \webserver \tools \\ \\ apache-openssl \logs
$ DestPath = \\ $ ComputerName \ $ DriveLetter $ \Log_Backup _ $((Get-Date).ToString('yyyy-MM-dd') )
New-Item -Path \\ $ ComputerName \ $ DriveLetter $ \ $ Path -type directory -Force //创建文件夹
Copy-Item - Recurse -Filter *。* -path $ SrcPath -destination $ DestPath -Force
ComputerName \
DriveLetter
\BMCSoftware\BMCPortalKit\webserver\tools\apache-打开sl\logs:术语
'\\
Hi all
Below is the code i am trying to execute for coping multiple files from one folder to other on remote server but i am getting this error
PS C:\Windows> D:\ScriptRepo\Smart_Backup_Create folders_by_Date.ps1
Hit Line breakpoint on 'D:\ScriptRepo\Smart_Backup_Create folders_by_Date.ps1:5'
[DBG]: PS C:\Windows>>
\\$ComputerName\$DriveLetter$\BMCSoftware\BMCPortalKit\webserver\tools\apache-openssl\logs : The term
'\\$ComputerName\$DriveLetter$\BMCSoftware\BMCPortalKit\webserver\tools\apache-openssl\logs' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\ScriptRepo\Smart_Backup_Create folders_by_Date.ps1:5 char:12
+ $SrcPath = \\$ComputerName\$DriveLetter$\BMCSoftware\BMCPortalKit\webserver\tool ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\$ComputerName...he-openssl\logs:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
[DBG]: PS C:\Windows>>
\\$ComputerName\$DriveLetter$\Log_Backup_$((Get-Date).ToString('yyyy-MM-dd')) : The term '\\$ComputerName\$DriveLetter$\Log_Backup_$((Get-Date).ToString('yyyy-MM-dd'))' is not recognized as
the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\ScriptRepo\Smart_Backup_Create folders_by_Date.ps1:6 char:13
+ $DestPath = \\$ComputerName\$DriveLetter$\Log_Backup_$((Get-Date).ToString('yyyy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\$ComputerName...('yyyy-MM-dd')):String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
[DBG]: PS C:\Windows>>
Directory: \\USDC1-BEMAPDC01\D$
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 8/14/2017 5:35 AM Log_Backup_2017-08-14
[DBG]: PS C:\Windows>>
Copy-Item : Cannot find path 'D:\BMCSoftware\BMCPortalKit\webserver\tools\apache-openssl\logs' because it does not exist.
At D:\ScriptRepo\Smart_Backup_Create folders_by_Date.ps1:8 char:1
+ Copy-Item -Recurse -Filter *.* -path $SrcPath -destination $DestPath -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (D:\BMCSoftware\...he-openssl\logs:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
Please let me know where i am doing wrong. Both the source and destination folders are in same server
What I have tried:
$ComputerName = "ServerName"
$DriveLetter = "D"
$CreateFolderPath = "Log_Backup_$((Get-Date).ToString('yyyy-MM-dd'))"
$SrcPath = \\$ComputerName\$DriveLetter$\BMCSoftware\BMCPortalKit\webserver\tools\apache-openssl\logs
$DestPath = \\$ComputerName\$DriveLetter$\Log_Backup_$((Get-Date).ToString('yyyy-MM-dd'))
New-Item -Path \\$ComputerName\$DriveLetter$\$Path -type directory -Force // Creating folder
Copy-Item -Recurse -Filter *.* -path $SrcPath -destination $DestPath -Force
ComputerName\
DriveLetter
\BMCSoftware\BMCPortalKit\webserver\tools\apache-openssl\logs : The term '\\
这篇关于复制远程服务器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!