Author Posts

August 14, 2018 at 6:30 pm

So I'm working on a PS Script to stand up new servers in our department.  That is working great so far!

My question is this.  When applying a DSC Config (via Push) and it requires the box to restart, is there anyway to make the PS script sit there and wait, and reconnect to show me the rest of the output?  It seems after the reboot, the config automagically kicks in again, so that's not the problem.  The problem is there can be no "I'm Done!" message to the person running the script if the reboot kicks off, and it does the rest under the covers.

Anyone have a solution for this?

The config is being kicked off as follows:

Start-DscConfiguration -ComputerName $ScriptComputerName -Path $configurationLocation -Wait -Force -Verbose

August 15, 2018 at 9:13 pm

You can use the DSC analytic logs to get the status.

you will have to enable it in the target system.

wevtutil.exe set-log “Microsoft-Windows-Dsc/Analytic” /q:True /e:true

once enabled, you can query it using Get-WinEvent cmdlet.

Get-WinEvent-ComputerName DestServerA “Microsoft-Windows-Dsc/Analytic” -Oldest

The message property is as is what is printing in the console.

August 24, 2018 at 12:29 pm

I ended up adding a SendEmail DSC Resource to just send out an email message when the config was complete.  This seems to be doing the trick for the moment, but I'll definitely look into this as well.  Thanks!

August 24, 2018 at 2:06 pm

A one off possibility...

When the compute restarts being doing a Test-NetConnection until the serve comes back online. When the computer comes back online you can then do a Test-DscConfiguration to verify the server is compliant with your configuration. This will give a bit cleaner output than trying to pull the event logs.