I am new to PowerShell and need some guidance on a script I am trying to create for automated reporting. My goal is to generate a daily report that pulls specific data from multiple sources and compiles it into a single CSV file.
This is what I am trying to accomplish here:
Combine the data from the above sources into a single CSV file.
The CSV should have columns for the date, source of the data, and the actual data points.
Schedule the script to run daily at a specific time using Task Scheduler.
Log the execution details and any errors to a separate log file.
A CSV file located on a network share: This file is updated daily by another process.
What is it you specifically need help with? Most forums related to Powershell aren’t places where people will just write code for you.
From your post it seems like you’ve got a pretty good idea of what you need to do (outlines like that are great), but what have you written so far?
You said:
Combine the data from the above sources into a single CSV file.
But you never specified your sources.
I would start by writing out what all of your sources are, and how their data is stored. This will dictate how you approach getting the data. I.e. Get-Content, Import-CSV, Invoke-RestMethod etc.
Once you’ve loaded the data into Powershell it should be trivial to manipulate the objects into a common key/value pair across all data sources.
Task scheduler should be easy enough, and you can look up most of it online. If you have specific errors your encountering you can ask about them here if you like, but I haven’t ran in to a Task Scheduler problem I couldn’t solve by searching.
I always encourage logging in Powershell scripts, especially if they run unattended. Write yourself a logging function so that you can call it repeatedly from within the script.
The last thing you say is:
I need to make a GET request and parse the JSON response.
So you do need to use Invoke-RestMethod on something. The default HTTP method is a GET and Invoke-RestMethod automatically leverages JSON so you should get nice object output as return.