How To Use PowerShell To Retrieve Configuration Settings Of DSC Nodes From A DSC Report Server
When a DSC node has been configured to send DSC reports to a Report Server, it will send both Consistency check reports and Local Configuration Manager (LCM) reports. Local Configuration Manager Reports will have some useful information about a node’s LCM settings that were configured when it was set up to pull from a Pull Server.
In this Video, Matt will show you how to query a node for its Agent ID. Then we will use that Agent ID to build a function that will retrieve the StatusData from the LocalConfigurationManager reports for that particular node. Once we have those reports, we will use another function that can be used to filter the data and display the settings that were changed on the node’s LCM.
Prerequisites include: PowerShell 5.0 or higher A DSC Pull Server DSC nodes configured to send reports to a Pull Server
Hello in this video I'm going to show you how to use powershell to retrieve configuration settings of DSC nodes from a DSC report server. Let's start with my DSC node called server one which I'm going to store in a variable next. I'm going to use invoke command to run get DSC local configuration manager on my node and take a look at the report managers property to verify that this node is configured to send its reports to my pull server. I could see under the server URL that it is in fact, configured correctly next. Let's run get DSC local configuration manager again to get the agent ID for my node. We're going to need to use the agent ID when querying the report server now that I have the agent ID. Let's store that in a variable. Next I have a function which I have built that will take the agent ID query. The report server, then convert the results from JSON and return, the reports for that node. Let's go ahead and run that function with the agent ID. There are going to be 2 different operation types that we can look for here consistency or local configuration manager since I want to retrieve the LCM settings. I'm going to filter by local configuration manager and get the most recent report. The report will give us some useful information about the job that ran but we're going to be interested in what's in the status data property. The status data is going to be in JSON format, so will need to convert that from JSON to view the results. Now we're starting to see some of the settings for this particular node. So let's drill a little bit deeper and take a look at the meta configuration property. This should look familiar since it's the same information. We got back when running get DSC local configuration manager. Except this is a snapshot of the settings that were configured when the node was set up. If I drill down into the configuration download manager setting I can see which pull server. This node was registered with and what configuration names that it is pulling so let's take what we know now and build a function that we can use to view some of the important settings that we might be interested in reporting on the first thing I'm going to do is store 3 agent IDs of nodes that I've already configured and have been registered with my pull server into a variable next. I'm going to use my get report function to retrieve the reports for my agent ID's and store them. In an array. Here, I have another function, which is going to go through each of my reports and pull out the status data settings that I'm interested in seeing so let's go ahead and run that and see what comes back. Now, I can see each time that my DSC nodes had their LCM configured and what settings were used to configure them. I can also see the errors for any failures that may have occurred. Now, if we want to take a look at a particular node. We can filter on the host name and look at just the reports for server 3 for example, in my results. I can see each time the LCM for server 3 was configured in which changes were made to the LCM settings. And that's how to use powershell to retrieve configuration settings of DSC nodes from a DSC report server thanks for watching.