Forum Discussion

Werner2024's avatar
Werner2024
Copper Contributor
Jan 25, 2024

Intune

good day

Hope someone can assist me, I want to create a intune package that copy a folder from a network server to the local C drive of the computer, after the copy has finish I want it to automatically deploy the installation file in the folder that's copied to the local C drive.

I have try many steps but it looks like the copy does not happen, is there any advice on how I can better this steps or any scripts I can use? any advice will be helpful.  

14 Replies

  • Uhh... how are you deploying that app? I assume in the system context? as the system account will probably not have access to that file share on the server...
    • Werner2024's avatar
      Werner2024
      Copper Contributor
      Hi Rudy

      Yes that's my thoughts also but was not sure if that could be the cause or is the script the issue, hens the logs did not show anything weird I figured maybe that might be an access issue.

      any suggestions what we can do to test the access? intune does run with a services account and I doubt that you can create a separate folder only allowing that account to the folder.
      • James_Pedersen's avatar
        James_Pedersen
        Copper Contributor
        Hi Werner,

        You can test the access by running your script locally as SYSTEM. You can do that by downloading PSEXEC.EXE from Microsoft (SysInternals Tools) and running "psexec.exe -accepteula -s -i cmd.exe" or "start \\live.sysinternals.com\tools\psexec.exe -accepteula -s -i cmd.exe"

        In the scenario you describe you would probably need to delegate Read rights on the source folder to something like "Everyone" to make this work.
  • Werner2024 These steps can be achieved with a powershell script that you can package as intunewin and then deploy as an app. Are you already doing these steps? If so, can you share the script with us?

    • Werner2024's avatar
      Werner2024
      Copper Contributor
      Hi Jos van der Vaart

      Thanks you for the reply, here is the script i am using noe, might not be the best but it works if you run it on the machine self, but not trough Intune

      $sourceFolderPath = " # Specify the network path to the shared folder
      $destinationFolderPath = # Specify the local destination path on your laptop
      $softwarelocation =

      #Write-Host $destinationFolderPath
      #Write-Host $sourceFolderPath


      # Create the destination folder if it does not exist
      if (-not (Test-Path -Path ${destinationFolderPath})) {
      try {
      New-Item -ItemType Directory -Path ${destinationFolderPath} -ErrorAction Stop
      Write-Host "Folder created at ${destinationFolderPath}"
      }
      catch {
      Write-Host "Error creating folder: ${destinationFolderPath}"
      return
      }
      }
      else {
      #Write-Host "Destination folder already exists."
      }

      # Use xcopy to copy files from the shared folder to the local destination
      try{
      $xcopyCommand = "Copy-Item -Path "File Location" -Destination C:\ -Recurse"
      Invoke-Expression -Command $xcopyCommand
      Write-Host "Files copied from ${sourceFolderPath} to ${destinationFolderPath}."
      }

      catch {
      Write-Host "Error copying files: $_"
      }

      #Wait for 15 seconds
      Start-Sleep -Milliseconds 15000

      cd $softwarelocation

      Start-Process -FilePath .\ "Install file"-ArgumentList "/S" -Wait

      • JosvanderVaart's avatar
        JosvanderVaart
        Iron Contributor
        Hi Werner,

        Thanks for sharing, but how do you roll out this script through Intune. Is this through an app or a script? I would advise you to at least roll it out as an app.

Resources