Storing CSV file when running PowerShell with Intune

Fattah N 1 Reputation point
2022-12-20T14:43:28.21+00:00

What are some options to save the CSV file when running the PowerShell script (imports the CSV) with Microsoft Endpoint with Intune?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
5,570 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ali AlEnezi 1,076 Reputation points
    2022-12-20T19:04:23.383+00:00

    Hello @Fattah N ,

    There are several options you can consider to save the CSV file when running a PowerShell script with Microsoft Endpoint Manager and Intune. Here are a few examples:

    Save the CSV file to a local folder on the device: You can use the "Out-File" cmdlet in PowerShell to save the CSV file to a local folder on the device. For example:

    Import-Csv C:\path\to\input.csv | Out-File C:\path\to\output.csv

    Save the CSV file to a network share: You can use the "Out-File" cmdlet in PowerShell to save the CSV file to a network share. For example:

    Import-Csv C:\path\to\input.csv | Out-File \server\share\output.csv

    Save the CSV file to a cloud storage service: You can use the "Out-File" cmdlet in PowerShell to save the CSV file to a cloud storage service like Azure Blob Storage or Amazon S3. For example:

    Import-Csv C:\path\to\input.csv | Out-File https://myaccount.blob.core.windows.net/mycontainer/output.csv

    All the best,

    0 comments No comments

  2. Crystal-MSFT 52,816 Reputation points Microsoft External Staff
    2022-12-21T01:26:27.303+00:00

    @Fattah N , From your description, it seems you are deploying a PowerShell script via Intune and in the script and you want to save the result into CSV file. If there's any misunderstanding, feel free to let us know.

    Based as I know, when we deploy PowerShell script, there's an option named "Run this script using the logged on credentials". Select Yes to run the script with the user's credentials on the device. Choose No (default) to run the script in the system context. So if the credential is system, I think you need to save it to local folder. For the detailed command, you can refer to alenezi's reply. If the script is run under current log on user credential and the user has permission on the network share, you can save there. Otherwise, save it to local folder. Here is a link about deploying PowerShell script in Intune for your reference:
    https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension

    Hope it can help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.