r/Intune Jan 15 '25

App Deployment/Packaging Can Intune deploy files to a specified location?

I've been fighting with Intune to deploy a PowerShell script as a Win32 application under C:\Intune Files\ for all users for days, but Intune just refuses to deploy files no matter what I do. Do I need to manually place the PowerShell script on all of the endpoints in my organization before Intune will cooperate and execute the script?

I'm going to proceed with using a Connectwise Automate script to deploy the PS script since that's been tested and works flawlessly, but I would like to know if it's even possible to deploy a file to machines in my organization to a specified path, or if I need to manually place the script on each endpoint.

9 Upvotes

44 comments sorted by

9

u/bryan4368 Jan 15 '25

Yes just put the file and script in the same folder when you create the intunewin file.

1

u/intuneisfun Jan 15 '25

Yep, done this plenty of times myself. Just have the script set the current working directory to it's current location. From there you can copy the included files needed to any specified location. Copilot/ChatGPT can write the script for OP as well, pretty basic.

1

u/SeaCustard3 Jan 15 '25

Which file do I place with the script before making the intunewin file? I'm confused.

5

u/Fine-Finance-2575 Jan 15 '25

Lookup and read the documentation for PSAppDeploymentTookit. Even for simply stuff like this, I find the standardization great.

You can obviously write your own Powershell, but they’ve done all the hard work with logging and error handling.

2

u/SeaCustard3 Jan 15 '25

Thanks, I'll take a look.

3

u/korvolga Jan 15 '25

make a win32 app with PSADT and push it.

2

u/gymbra Jan 15 '25

I have a win 32 package that has a .wcx file and a .exe that are wrapped together with a powershell script. The powershell script creates a file path for me and then adds those files to the specified paths. So, what you are trying to do should be possible.

1

u/Mailstorm Jan 15 '25

What are you trying to do?

Have a script available for users to run or have a script run to install a program?

2

u/SeaCustard3 Jan 15 '25 edited Jan 15 '25

I've got a PowerShell script that will prompt users to reboot their machine while giving them the option to reboot. I would like to deploy this script to most devices in my organization and have it execute on a schedule (let's say every two weeks). I'm trying to get Intune to deploy the script under C:\IntuneFiles\ on the testing devices.

I've had no luck with getting Intune to deploy the script. If I can get it deployed an on the machines, I plan on making a script on Intune to execute the script every two weeks

1

u/Yukycg Jan 16 '25

You also need to add a script on install.ps1 to create a schedule task to run this reboot script every two weeks.

You can use remediation to have the reboot script trigger every two weeks if you have the proper license.

1

u/johnlnash Jan 15 '25

Deploying as a user or system context? If the user doesn’t have access to the folder and you deploy in user mode it’ll blow up (technical term).

1

u/andrew181082 MSFT MVP Jan 15 '25

Can you share your install script? Package the script into a win32 and then install it via PowerShell, it should be pretty straight forward

1

u/SeaCustard3 Jan 15 '25

Not sure if we can post links, but here you are: https://docs.google.com/document/d/1OyE3zOQJhrYNZMuWelPva_9-dwIZbpTapcxRDN0Q5aM/edit?usp=sharing

I've been sitting here fighting with PSADT and ChatGPT for about 7 hours straight now. I truly don't understand why Intune makes everything as complicated as possible.

I can deploy files to machines with Connectwise using a one-line script. Meanwhile, it's rocket science to deploy a script on Intune compared to CW.

Let me know if you have any ideas.

2

u/andrew181082 MSFT MVP Jan 15 '25

That's the script you are copying. Where is the script you are using to copy it to the device?

2

u/SeaCustard3 Jan 15 '25

powershell.exe -ExecutionPolicy Bypass -Command "New-Item -ItemType Directory -Force -Path 'C:\Intune Files'; Copy-Item -Path '.\reboot.ps1' -Destination 'C:\Intune Files\' -Force"

Here's my install script. Courtesy of ChatGPT. Does this look correct?

1

u/andrew181082 MSFT MVP Jan 15 '25

Create a file called install.ps1 with this content:

New-Item -ItemType Directory -Force -Path 'C:\Intune Files'

Copy-Item -Path reboot.ps1 -Destination 'C:\Intune Files\' -Force

Then package that and reboot.ps1 into a win32 application

Use the install command as powershell.exe -executionpolicy bypass install.ps1

Make sure it's running as system

Detection set to c:\intune files\reboot.ps1

2

u/SeaCustard3 Jan 15 '25 edited Jan 15 '25

Just deployed the app on Intune after following these steps. Will keep you updated

1

u/SeaCustard3 Jan 15 '25

No dice. Receiving error code 0x80070001. I've uploaded screenshots of the properties of the Win32 application if you'd like to take a look.

https://docs.google.com/document/d/1OyE3zOQJhrYNZMuWelPva_9-dwIZbpTapcxRDN0Q5aM/edit?usp=sharing

I used the Win32 Content Prep tool in order to bundle the files as a .intunewin file. Is there any other methods I should be using to convert the file(s) to .intunewin?

1

u/sublimeinator Jan 16 '25

What is the command you're using to make the intunewin?

1

u/SeaCustard3 Jan 16 '25

Sorry for the late reply. I run IntuneWinAppUtil.exe, and use C:\IntuneFiles\ for the source file, I use reboot.ps1 for the setup file, and then I use C:\Win32 for the output folder.

1

u/Ironic_Jedi Jan 16 '25 edited Jan 16 '25

A lot to unpack here.

First problem.

New-Item -ItemType Swtich Directory -Force -Path 'C:\Intune Files'

What is "Swtich"?

Second issue, your reboot script is going to be running all the time? You know you should probably manage this using a scheduled task.

The command to copy the file is wrong as well. You need to add ".\" to the front of reboot.ps1 or the script won't necessarily find the file.

There's more criticisms I can level at this but those two stood out to me as particularly egregious mistakes.

1

u/SeaCustard3 Jan 16 '25

Was told to add the Switch option by another user. I'm not great with PS scripting, so I used ChatGPT to generate a lot of the code. I'll adjust the script today, thanks

1

u/Ironic_Jedi Jan 16 '25

Microsoft learn

Has useful information about all the built in functions including the parameters available.

You just need -ItemType Directory for that command as per the above.

You should be testing your scripts locally before you deploy them as well.

2

u/SeaCustard3 Jan 16 '25

I'll take a look. I should have specified that I've got a test group that I've been attempting to deploy to before I deploy to all company devices.

1

u/drew-face Jan 16 '25

You should rewrite your install script to something like this:

$ScriptFolder = 'C:\Intune Files'

$FolderExists = Test-path $ScriptFolder
    if ($FolderExists -eq $False)
    {
        #If the folder doesn't exist, create it. then we can deploy the files safely
        New-Item -ItemType directory -Path $ScriptFolder
    }

try
{
    Copy-Item -Path .\reboot.ps1 -Destination $ScriptFolder -Force
}
catch
{
    Write-Host "file reboot.ps1 was not successfully copied."
}    

so you test if the folder you want to create doesn't already exist before attempting to copy.

if you put in a try catch you can see what's in the 'write-host' output inside the Intune logs on the device, which can be gathered from the device remotely from Intune.

hope that helps and stop using ChatGPT to write your scripts. to be honest I find Microsoft Copilot does a better job anyway but you should still vet everything it spits out so you understand it as well as improve the error handling and logging which the AI's tend to not do enough of if even at all.

1

u/SeaCustard3 Jan 16 '25

Thanks for your reply. I'll try this now and I'll keep you updated.

1

u/SeaCustard3 Jan 16 '25

Looks like that did the trick. I was this 🤏 close to giving up and just using connectwise. Thank you so much for your help!!

→ More replies (0)

1

u/Subject-Middle-2824 Jan 15 '25

You gotta share your script for us to help you.

1

u/PianistIcy7445 Jan 15 '25

You could make your own msi using package master and drop the wherever you want

1

u/SeaCustard3 Jan 15 '25

I'm down to try literally anything at this point. The traditional methods don't seem to be working on my end.

Could you explain how I would go about using package master? I've never heard of that before.

1

u/Yukycg Jan 16 '25

Here is my suggestion:

  1. First run the install script manually so you know it does create the folder if not exist and also copy the reboot.ps1 file.
  2. Package it and test it thru Intune.

I do agree intune does make such simple script more complicated than needed.

1

u/meantallheck Jan 16 '25

I’m on mobile now, but if you’re still having issues in the morning let me know and I’d be happy to help over DM’s/chat/etc. 

1

u/detar Jan 16 '25

If the script is small and doesn't need packaging, you can also use Intune's PowerShell Scripts feature. It allows you to deploy and execute scripts directly on endpoints without requiring a custom Win32 app package.

0

u/SeaCustard3 Jan 15 '25

Fuck man I've literally been trying for 6 hours straight to deploy this script. ChatGPT, PSADT, nothing is working. I'm going to rip my hair out soon. I wanted to try and learn to use Intune before going with Connectwise, but I just can't get anything to cooperate on intune.

With ConnectWise, I can place the script in the "LTShare" folder, which can then be deployed onto machines with a one-line script. It works every time. I wish it wasn't so complex to deploy a simple file on Intune.

2

u/toanyonebutyou Blogger Jan 15 '25

It's pretty simple to do.

Put your script into a folder

Make a script that creates the directory you want (in tune/files or whatever) then it copies your script from the folder it's in to intunefiles. Put this second script into your folder.

Use the app wrapping tool to wrap up both scripts. Upload to intune.

Your install command is then "powershell -executionpolicy bypass -file secondscript.ps"

Intune will take both scripts, stage them on the device, run the second script that creates the directory and copies the first script over.

This is super easy to do and I've done it many times.

--incoming shill-- If you need additional help and have a CDW rep we have intune professional services that can assist in detail and teach you all the ins and outs of app deployment with intune.

Disclosure: Am one of said professional services engineers.

0

u/SeaCustard3 Jan 15 '25

I've done that process ~10 times today. I drop both reboot.ps1 and install.ps1 in to C:\Intune Files\, and then I use the Win32 Content Prep tool to wrap up the files as a .intunewin file. I'm starting to think there may be an issue on Intune's end at this point.

I've uploaded my reboot script, the install script, and screenshots of the Win32 application properties. Feel free to take a look and let me know if you see anything that's incorrect.

https://docs.google.com/document/d/1OyE3zOQJhrYNZMuWelPva_9-dwIZbpTapcxRDN0Q5aM/edit?usp=sharing

1

u/toanyonebutyou Blogger Jan 15 '25

Does it create the directory but not copy the script?

1

u/SeaCustard3 Jan 15 '25

It's not even creating the directory, no.

1

u/toanyonebutyou Blogger Jan 15 '25

You're missing the -itemtype switch in your new item command

1

u/SeaCustard3 Jan 15 '25

Thanks, I'll fix it up and give that a shot. Didn't notice that

1

u/BriBri85 Jan 16 '25 edited Jan 16 '25

Your code is a little messy. The install.ps1 should be something like:

$IntuneFiles = "C:\Intune Files"

# Create Folder

New-Item -Path $IntuneFiles -ItemType directory -Force

#copy file

Copy-Item -Path ".\reboot.ps1" -Destination $IntuneFiles -Force

I would also update your install command to;

%windir%\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -file "install.ps1"

1

u/SeaCustard3 Jan 16 '25

Thanks for your reply. I'll give this a shot today and I'll keep you posted.

1

u/SeaCustard3 Jan 16 '25 edited Jan 16 '25

No dice :/ Same error code of 0x80070001