Tech Accelerator: Microsoft Intune Suite
Apr 11 2023 08:00 AM - Apr 12 2023 11:00 AM (PDT)

Execute PowerShell script and collect output

Regular Contributor

I am trying to execute a PowerShell script on all Intune managed machines and collect the output of the script afterwards.



Echo "Hello World from $env:computername"



I managed to upload and execute the PowerShell script using Devices > Policy > Scripts sections, but I cannot get the output of the script.


What is the right approach to collect such data? Where can I see the "Hello world from MY-DEVICE" printed, or what system should I use to retrieve the information?

3 Replies

Can you give us some more info what you are trying to accomplish? so we can help you

An example to write the output to a file

Write-Error -Message "Forced Fail" -Category OperationStopped
mkdir "c:\temp"
echo "Forced Fail" | out-file c:\temp\Fail.txt
Thank you!

There are around 50 intune managed machines in our org. I need to execcute the PowerShell script on all of those machines (this I can accomplich) and collect the output. Your example is perfect for showing how the write a file to C:\Temp, but how can I, as an intune admin collect the file from the 50 intune managed machines?

You could take a look on how I did the same with the laps solution or bitlocker.
A perfect method to get back some information and reports...