Forum Discussion
Kiril
Jun 15, 2021Steel Contributor
Execute PowerShell script and collect output
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?
- Hi,
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- KirilSteel ContributorThank 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?- Hi,
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...
https://call4cloud.nl/2021/05/the-laps-reloaded/