Forum Discussion
Werner2024
Jan 25, 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
JosvanderVaart
Jan 25, 2024Iron 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.
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.
- Werner2024Jan 25, 2024Copper ContributorI have a poweshell script that I have build an .intunewin package, then from there I upload into Intune as an Windows app (Win32) app to deploy.