dsccommunity / ConfigMgrCBDsc

This module contains DSC resources for the management and configuration of Microsoft System Center Configuration Manager Current Branch (ConfigMgrCB).
MIT License
27 stars 8 forks source link

Issue with Collections based on Queries (Convert-DataToExcel.ps1) #105

Closed PaulSIsaac closed 2 years ago

PaulSIsaac commented 2 years ago

There is an issue with the collection conversion, when the collections make use of single quotes (') within the query. When you do this, the code wraps the whole Select statement with a second set of single quotes, which breaks the code.

For example I have a query that finds all Dell devices:

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like '%Dell%'

As you can see, I am using single quotes '%Dell'

Within the psd file the resultant line comes up as 'select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like '%Dell%''

If I replace the single quotes wrapping the Select query with double, it does work.