Reporting and Logging

If you are looking for the returned reports from each function check UcmPsTools Cmdlet Reporting

UCM Report Cmdlets

A collection of cmdlets for creating, managing and exporting reports

Initialize-UcmReport New-UcmReportItem New-UcmReportStep Complete-UcmReport Export-UcmHtmlReport Export-UcmCsvReport

Other Reporting Cmdlets

Search-UcmCsOnPremNumberRange - Find what resource is using a number on-prem Write-UcmLog - A function used by almost every function in UcmPsTools. Great logging utility

About UCM Reporting Cmdlets

These cmdlets allow you to track the progress of actions in your scripts which you can then export to a variety of formats including HTML and CSV (more info)

Turn your post-script reports from this

into HTML like this

Or CSV's like this

Simply start by calling Initialize-UcmReport!

Using the UCM Report Cmdlets

Start off by calling Initialize-UcmReport, this creates a global variable to store the status of the report.

Then when you're ready, add a line to the report. Call New-UcmReportItem. This creates a new PSObject to track the status against.

Each ReportItem is its own item for tracking and can have multiple ReportSteps, aka actions associated with it. For example, above, we create a new ReportItem for every user we are processing.

New-UcmReportItem Parameters

New-UcmReportItem expects two parameters -LineTitle: This is the title of the first row in the report and should be the same for every ReportItem. In the above example, we used "Username" -LineMessage: This is the value we are setting the first cell to and should be unique to prevent conflicts. In the above example "AppleJack" was used the first time we called New-UcmReportItem, and "Discord" the second time

Once you have created a ReportItem, we can start logging steps against it using New-UcmReportStep

ReportSteps are typically items performed against a ReportItem so again using the report above, each step such as assigning a licence, applying a policy etc to a user (the ReportItem) and can be thought of as a column in the row.

New-UcmReportStep Parameters

New-UcmReportSteps expects two parameters -StepName: This is the name of the Step, translating to the title of the column for each of the rows of the first row, for example, "Enable User" -StepResult: This is the value of the action performed. This is a freeform field, but should it contain "OK" "Warn" or "Error", HTML reports will automatically have their cells coloured Green, Yellow and Red respectively.

If you add any of the following keywords to the ReportStep items, their cells will be colour coded based on the keyword "OK": Green "Warn"/"Warning": Yellow "Error": Red

Once you have finished working with that item, user, or whatever and are ready to move on to the next line, Call New-UcmReportItem with the next item, or if you're ready to wrap things up, call Complete-UcmReport to add the last step into the report object. Ready to be exported using either Export-UcmCsvReport or Export-UcmHtmlReport (you can call both!)

Last updated