Forum Discussion
alazarg
Jun 24, 2023Copper Contributor
Deploy File to Intune Enrolled Devices as Win-32 App
I had a request to Deploy a pdf file to user's desktop and could not find clear documentation, hence here is how I successfully deployed it and decided to share is with this amazing community.
Deploy File to Intune Enrolled Devices
Deploy a file to Intune enrolled device's to "C:\Users\Public\Desktop" through Intune
Step 1: Prepare the files:
- The File
- Install-file.ps1
- Remove-file.ps1
- Detect-file.ps1
Step 2" Create an Install, Remove & Detect script & save each scripts
A. Install:
#Installation Script: Install-file.ps1
$FileName = "FileToDesktop.pdf"
$ScriptPath = [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Definition)
Copy-Item -Path "$ScriptPath\$FileName" -Destination "$Env:Public\Desktop"
B. Remove:
# Remove Installation: Remove-file.ps1
$FileName = "FileToDesktop.pdf"
Remove-Item -Path "$Env:Public\Desktop\$FileName"
C. Detect: # save this in a separate folder
#Detect File : Detect-file.ps1
$FileName = "FileToDesktop.pdf"
if (Test-Path -Path "$Env:Public\Desktop\$FileName"){
Write-Output "0"
}
Step 3: collect Install-file .ps1, Remove-file .ps1 and the required files in one folder as shown above and create an Intune installation Package.
PS C:\Intune\WindowsIntunePrepTool> .\IntuneWinAppUtil.exe
Please specify the source folder: C:\DeployFile\FileToDeploy
Please specify the setup file: FileToDesktop.pdf
Please specify the output folder: C:\DeployFile
Do you want to specify catalog folder (Y/N)?N
Step 4. Deploy Intune installation file with the following commands
- Upload the IntunePackage as " App : Windows app (Win32)
- Install Command: %windir%\system32\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -file "Install-file.ps1"
- Uninstall Command: %windir%\system32\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -file "Remove-file.ps1"
- Operating system architecture = select both 32/64-bit
- Detection rule: use custom detection script and upload the Detect script created above.
Following the above steps, it is straight forward and easy to deploy a file to Intune Enrolled devices when required.
- HappyPufferCopper Contributor
This doesn't look too old of a post so hoping for a reply. This is all great stuff. Thanks.
I was wondering, if its possible to modify this to place a folder on the desktop with the files in them. I ask because we use public PCs for job seekers and they want a folder of templates on the desktop. I am using the Shared User configuration in Intune and wanted to have it so the folder is there with the contents. The folder and the files are on my PC.
- JValCopper Contributor
In your powershell script just add the line to create the folder:
New-Item -ItemType directory -Force -path "$Env:Public\Desktop\FolderName"
- rahuljindal-MVPBronze Contributor
- ChrisMorris22Copper Contributor
Great post alazarg
I wanted to know would your install script would work for copying a file from my C drive to ProgramData on other peoples computers by changing the destination path to being something such as $env:ProgramData\Microsoft\Windows\Start Menu\Programs\DesiredLocation.After testing this, I can confirm that this worked a treat! Thank you so much!!
- ThanasisSCopper ContributorHell, I followed your instructions exactly. I have one question: if I just want to remove the file, should I assign a group to the uninstall? If the uninstall runs, will the script you have in the detection rule stop the uninstall from completing and removing the file?
- cliftonmason21Copper ContributorThese steps are super easy to follow! I'm trying to perform these steps but with a folder but I seem to have an issue. Is there anything in these steps that needs to be performed differently when attempting to package an entire folder?
- StuartK73Iron Contributor
Hi Buddy
Great informative post.
How can I get this to work on a standalone EXE file that is in a folder with what looks like lots of dependencies?
I have tried adding my EXE and it's files as well as your 2 files to the Win32 Tool but the install fails.
Any clues?
Info appreciated
- DeanHuffordCopper Contributor
I have an application (Therefore Navigator by App Extender via Cannon) which has several Windows dependencies. It looks like I have to use Orca to modify the installation package and identify the dependencies, and manage their installation. I put a little bit of effort into it but I ran out of clock cycles and had to move on. Orac is
- alazargCopper ContributorKay_Urban
That is a good question!
To deploy multiple file using one deployment action, you can modify the install, remove and detect scripts. for example to modify "install-file.ps1"
-----------------------------
#Installation Script: Install-file.ps1
$FileName1 = "FileToDesktop1.pdf"
$FileName2 = "FileToDesktop2.pdf"
$FileName3 = "FileToDesktop3.pdf"
$ScriptPath = [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Definition)
Copy-Item -Path "$ScriptPath\$FileName1" -Destination "$Env:Public\Desktop"
Copy-Item -Path "$ScriptPath\$FileName2" -Destination "$Env:Public\Desktop"
Copy-Item -Path "$ScriptPath\$FileName3" -Destination "$Env:Public\Desktop"
-----------------------------------------
I hope this helps.- jordanpinedaCopper Contributor
For multiple files in one, how would you save the files to make IntuneWinAppUtil.exe take them in?
- knutkCopper ContributorThank you!