Forum Discussion
Werner2024
Jan 24, 2024Copper Contributor
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 automat...
Werner2024
Jan 25, 2024Copper 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
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
TimBosch
Jan 25, 2024Brass Contributor
Hey Werner, Thanks for sharing.
Have you tried running it locally and could you share a anonimised error log?
it looks like that you also install it in the same script.
Maybe it's easier to use a .zip containing the set of files, copying it over and using unzip archive command to achieve easier copying to the folder you want,
Expand-Archive -LiteralPath <PathToZipFile> -DestinationPath <PathToDestination>
I have done this due to an AX installation and used a zip to move the 4gb big file towards a temp folder on the endpoint, then unzipping it and using the install script to install it.
Have you tried running it locally and could you share a anonimised error log?
it looks like that you also install it in the same script.
Maybe it's easier to use a .zip containing the set of files, copying it over and using unzip archive command to achieve easier copying to the folder you want,
Expand-Archive -LiteralPath <PathToZipFile> -DestinationPath <PathToDestination>
I have done this due to an AX installation and used a zip to move the 4gb big file towards a temp folder on the endpoint, then unzipping it and using the install script to install it.
- Werner2024Jan 25, 2024Copper ContributorHi Tim,
Thanks for the info will definitely give it a try, my only concern is the copy process from the server to the local machine does not happen, so I am stuck there.
The error logs does not give me any error's or false status, the app show installed on Intune console but on the endpoint nothing is happening. what I have notice is that it shows that the app is downloading and installing then a min after that it fails.- TimBoschJan 29, 2024Brass ContributorHey Werner,
No problem! What is the command you are using in intune? maybe the installment is dedicated to run as USER with Elevated rights.
greets,
tim- Werner2024Feb 07, 2024Copper ContributorI use the below command
Powershell.exe -NoProfile -ExecutionPolicy ByPass -File .\script.ps1