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