/build/static/layout/Breadcrumb_cap_w.png

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)

Posted by: ThebeMatshana 9 years ago
Senior White Belt
0

Try XCOPY.

For example: xcopy %~dp0*.* C:\Users\Public\Pictures\ /E /H /R /K /Y

good luck...



Posted by: anonymous_9363 9 years ago
Red Belt
0
How do you have the script set to run? If it's the default, it'll be running using the local System account which, as you know, has no network access. You'll need to set it to run in logged-in user Context.
Posted by: Thegunner 9 years ago
Second Degree Green Belt
0
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
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ