Can you provide an SCCM 2012 package/program command line I can use to copy files from a server\share to a local PC via robocopy or powershell?
I need to copy files from a server\share to a local machine using robocopy or powershell. I can successfully run via a command prompt this command line: %windir%\system32\robocopy.exe \\GHJKL000\Temp\FileCopy\ScreenSaverFiles C:\Users\Public\Pictures *.* /S /E /COPYALL /R:1000000 /W:30. However, when I add this command line to a program and try run this via SCCM 2012, it doesn't copy. Do I need to add quotes?
Thx in advance
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
ThebeMatshana
9 years ago
Posted by:
anonymous_9363
9 years ago
Posted by:
Thegunner
9 years ago
Give this a go, i have just created it today for a task, it works in my test environment.
Put the code in a PS1 file and you should be good to go.
$HostName = Servername'
$Path = "Path on server to create folder"
$TestPing = Test-Connection $HostName -count 1 -Quiet -ErrorAction SilentlyContinue #Checks to see if server is up
$ValidPath = Test-path $Path #Validates path exisit
#If statement checks to see if path exist and server is up are both true, if the path exist all is good, if not it creates it.
IF (($ValidPath -eq $True) -and ($testping -eq $True)){
Write-Host 'Path Exist! - '$Path -ForegroundColor Green
}
Else{
Write-Host 'Path Does Not Exist!' -ForegroundColor Yellow
New-Item -ItemType Directory -Path $Path
$ValidPath = Test-path $Path
If ($ValidPath) {Write-Host 'Path has been created' -ForegroundColor Green}Else{'Path does not exist'}
}
#Copy files to host, if path exist or once path has been created - take of -Confirm this will prompt for confirmation to run or you can use -Whatif to simulate if it will work otherwise delete to run in live mode
Copy-Item -Path "Path of source files" -Destination $Path -Recurse -Force -Confirm
Put the code in a PS1 file and you should be good to go.
$HostName = Servername'
$Path = "Path on server to create folder"
$TestPing = Test-Connection $HostName -count 1 -Quiet -ErrorAction SilentlyContinue #Checks to see if server is up
$ValidPath = Test-path $Path #Validates path exisit
#If statement checks to see if path exist and server is up are both true, if the path exist all is good, if not it creates it.
IF (($ValidPath -eq $True) -and ($testping -eq $True)){
Write-Host 'Path Exist! - '$Path -ForegroundColor Green
}
Else{
Write-Host 'Path Does Not Exist!' -ForegroundColor Yellow
New-Item -ItemType Directory -Path $Path
$ValidPath = Test-path $Path
If ($ValidPath) {Write-Host 'Path has been created' -ForegroundColor Green}Else{'Path does not exist'}
}
#Copy files to host, if path exist or once path has been created - take of -Confirm this will prompt for confirmation to run or you can use -Whatif to simulate if it will work otherwise delete to run in live mode
Copy-Item -Path "Path of source files" -Destination $Path -Recurse -Force -Confirm