Skip to content

Commit

Permalink
Updated and added more queries for part 8
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniehack committed May 20, 2024
1 parent 38ab6b2 commit b348c7a
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Dax Measures/Count_Active_Last_30Days.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Count_Active_In_Last_30Days =
VAR DATA = CALCULATE(
DISTINCTCOUNT('deviceManagement/managedDevices/'[id]),
DATESINPERIOD(
'deviceManagement/managedDevices/'[lastSyncDateTime].[Date],
TODAY(),
-30
,DAY
))
RETURN
IF(ISBLANK(DATA),0,DATA)
9 changes: 9 additions & 0 deletions Dax Measures/Count_Encypted_Total.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Count_Total_Encrypted =
VAR Number =
CALCULATE(
DISTINCTCOUNT(
'deviceManagement/managedDevices/'[id]),
'deviceManagement/managedDevices/'[isEncrypted] = "Encrypted"
)
Return
If(ISBLANK(Number),0,Number)
11 changes: 11 additions & 0 deletions Dax Measures/Count_NotCompliant_Windows.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Count_NotCompliant_Windows =
VAR Number =
CALCULATE(
DISTINCTCOUNT(
'deviceManagement/managedDevices/'[id]),
AND(
'deviceManagement/managedDevices/'[complianceState] <> "Compliant",
'deviceManagement/managedDevices/'[operatingSystem] = "Windows")
)
Return
If(ISBLANK(Number),0,Number)
11 changes: 11 additions & 0 deletions Dax Measures/Count_NotEncrypted_Windows.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Count_NotEncrypted_Windows =
VAR Number =
CALCULATE(
DISTINCTCOUNT(
'deviceManagement/managedDevices/'[id]),
AND(
'deviceManagement/managedDevices/'[isEncrypted] <> "Encrypted",
'deviceManagement/managedDevices/'[operatingSystem] = "Windows")
)
Return
If(ISBLANK(Number),0,Number)
Empty file.
9 changes: 9 additions & 0 deletions Dax Measures/Count_SKU_Pro.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Count_SKU_Pro =
VAR Number =
CALCULATE(
DISTINCTCOUNT(
'deviceManagement/managedDevices/'[id]),
'deviceManagement/managedDevices/'[skuFamily] = "Pro"
)
Return
If(ISBLANK(Number),0,Number)
15 changes: 15 additions & 0 deletions Dax Measures/Enrolled_This_Month_Andoroid.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Enrolled_This_Month_Android =
VAR PreviousMonthEndDate = EOMONTH(TODAY(), -1)
VAR EnrolledCount =
CALCULATE(
COUNTROWS('deviceManagement/managedDevices/'),
FILTER(
'deviceManagement/managedDevices/',
AND(
'deviceManagement/managedDevices/'[enrolledDateTime] >= PreviousMonthEndDate,
'deviceManagement/managedDevices/'[operatingSystem] = "Android"
)
)
)
RETURN
IF(ISBLANK(EnrolledCount), 0, EnrolledCount)
15 changes: 15 additions & 0 deletions Dax Measures/Enrolled_This_Month_Windows.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Enrolled_This_Month_Windows =
VAR PreviousMonthEndDate = EOMONTH(TODAY(), -1)
VAR EnrolledCount =
CALCULATE(
COUNTROWS('deviceManagement/managedDevices/'),
FILTER(
'deviceManagement/managedDevices/',
AND(
'deviceManagement/managedDevices/'[enrolledDateTime] >= PreviousMonthEndDate,
'deviceManagement/managedDevices/'[operatingSystem] = "Windows"
)
)
)
RETURN
IF(ISBLANK(EnrolledCount), 0, EnrolledCount)
15 changes: 15 additions & 0 deletions Dax Measures/Enrolled_This_Month_iOS.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Enrolled_This_Month_iOS =
VAR PreviousMonthEndDate = EOMONTH(TODAY(), -1)
VAR EnrolledCount =
CALCULATE(
COUNTROWS('deviceManagement/managedDevices/'),
FILTER(
'deviceManagement/managedDevices/',
AND(
'deviceManagement/managedDevices/'[enrolledDateTime] >= PreviousMonthEndDate,
'deviceManagement/managedDevices/'[operatingSystem] = "iOS"
)
)
)
RETURN
IF(ISBLANK(EnrolledCount), 0, EnrolledCount)
15 changes: 15 additions & 0 deletions Dax Measures/Enrolled_This_Month_macOS.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Enrolled_This_Month_macOS =
VAR PreviousMonthEndDate = EOMONTH(TODAY(), -1)
VAR EnrolledCount =
CALCULATE(
COUNTROWS('deviceManagement/managedDevices/'),
FILTER(
'deviceManagement/managedDevices/',
AND(
'deviceManagement/managedDevices/'[enrolledDateTime] >= PreviousMonthEndDate,
'deviceManagement/managedDevices/'[operatingSystem] = "macOS"
)
)
)
RETURN
IF(ISBLANK(EnrolledCount), 0, EnrolledCount)
9 changes: 9 additions & 0 deletions Dax Measures/Patch_Rank_Column.pq
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Patch Rank = RANKX(
FILTER(
'XT - Windows Client Patching Data',
'XT - Windows Client Patching Data'[Build Number] =
EARLIER(
'XT - Windows Client Patching Data'[Build Number]
)
),
'XT - Windows Client Patching Data'[Patch Number])
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
let

// Application Registration Permissions needed to make this call : DeviceManagementServiceConfig.Read.All
// : DeviceManagementConfiguration.Read.All

// Microsoft Graph URL
Endpoint = "https://graph.microsoft.com/",
Version = "beta/",
Resource = "deviceManagement/windowsAutopilotDeviceIdentities/",
QueryParams = "",
GraphURL = Endpoint & Version & Resource & QueryParams,

// Get Bearer Token Using Function
Bearer = #"Get-BearerToken" (TenantID, AppID, SecretID, Endpoint),

// Logic App to handle pagination
LABody = "{
""GraphUrl"":""" & GraphURL & """,
""Bearer"":""" & Bearer & """
}",
LogicApp = Json.Document(Web.Contents(#"MSGraphCall", [Headers=[#"Content-Type"="application/json"],Content = Text.ToBinary(LABody)])),
Value = LogicApp[value],

// Output Processing
#"Converted to Table" = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "deploymentProfileAssignmentStatus", "deploymentProfileAssignmentDetailedStatus", "deploymentProfileAssignedDateTime", "groupTag", "purchaseOrderIdentifier", "serialNumber", "productKey", "manufacturer", "model", "enrollmentState", "lastContactedDateTime", "addressableUserName", "userPrincipalName", "resourceName", "skuNumber", "systemFamily", "azureActiveDirectoryDeviceId", "azureAdDeviceId", "managedDeviceId", "displayName", "deviceAccountUpn", "deviceAccountPassword", "deviceFriendlyName", "remediationState", "remediationStateLastModifiedDateTime", "userlessEnrollmentStatus"}, {"id", "deploymentProfileAssignmentStatus", "deploymentProfileAssignmentDetailedStatus", "deploymentProfileAssignedDateTime", "groupTag", "purchaseOrderIdentifier", "serialNumber", "productKey", "manufacturer", "model", "enrollmentState", "lastContactedDateTime", "addressableUserName", "userPrincipalName", "resourceName", "skuNumber", "systemFamily", "azureActiveDirectoryDeviceId", "azureAdDeviceId", "managedDeviceId", "displayName", "deviceAccountUpn", "deviceAccountPassword", "deviceFriendlyName", "remediationState", "remediationStateLastModifiedDateTime", "userlessEnrollmentStatus"})
in
#"Expanded Column1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
let

// Application Registration Permissions needed to make this call : DeviceManagementServiceConfig.Read.All
// : DeviceManagementConfiguration.Read.All

// Microsoft Graph URL
Endpoint = "https://graph.microsoft.com/",
Version = "beta/",
Resource = "deviceManagement/windowsAutopilotDeviceIdentities/",
QueryParams = "",
GraphURL = Endpoint & Version & Resource & QueryParams,

// Logic App to handle pagination
LABody = "{
""GraphUrl"":""" & GraphURL & """,
""TenantID"":""" & TenantID & """,
""AppID"":""" & AppID & """,
""SecretID"":""" & SecretID & """,
""Audience"":""" & Endpoint & """
}",
LogicApp = Json.Document(Web.Contents(#"MSGraphCall-NoBearer", [Headers=[#"Content-Type"="application/json"],Content = Text.ToBinary(LABody)])),
Value = LogicApp[value],

// Output Processing
#"Converted to Table" = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "deploymentProfileAssignmentStatus", "deploymentProfileAssignmentDetailedStatus", "deploymentProfileAssignedDateTime", "groupTag", "purchaseOrderIdentifier", "serialNumber", "productKey", "manufacturer", "model", "enrollmentState", "lastContactedDateTime", "addressableUserName", "userPrincipalName", "resourceName", "skuNumber", "systemFamily", "azureActiveDirectoryDeviceId", "azureAdDeviceId", "managedDeviceId", "displayName", "deviceAccountUpn", "deviceAccountPassword", "deviceFriendlyName", "remediationState", "remediationStateLastModifiedDateTime", "userlessEnrollmentStatus"}, {"id", "deploymentProfileAssignmentStatus", "deploymentProfileAssignmentDetailedStatus", "deploymentProfileAssignedDateTime", "groupTag", "purchaseOrderIdentifier", "serialNumber", "productKey", "manufacturer", "model", "enrollmentState", "lastContactedDateTime", "addressableUserName", "userPrincipalName", "resourceName", "skuNumber", "systemFamily", "azureActiveDirectoryDeviceId", "azureAdDeviceId", "managedDeviceId", "displayName", "deviceAccountUpn", "deviceAccountPassword", "deviceFriendlyName", "remediationState", "remediationStateLastModifiedDateTime", "userlessEnrollmentStatus"})

in
#"Expanded Column1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
let

// Application Registration Permissions needed to make this call : DeviceManagementServiceConfig.Read.All
// : DeviceManagementConfiguration.Read.All

// Microsoft Graph URL
Endpoint = "https://graph.microsoft.com/",
Version = "beta/",
Resource = "deviceManagement/windowsAutopilotDeviceIdentities/",
QueryParams = "",
GraphURL = Endpoint & Version & Resource & QueryParams,

// Get an Access Token to make Graph Calls (uses Application Registration)
Bearer = #"Get-BearerToken" (TenantID, AppID, SecretID, Endpoint),

// ODataFeed to process Graph Call
// https://learn.microsoft.com/en-us/powerquery-m/odata-feed
OData = OData.Feed (
GraphURL,
[ Authorization = Bearer ],
[
ExcludedFromCacheKey = {"Authorization"},
ODataVersion = 4,
Implementation = "2.0",
OmitValues = ODataOmitValues.Nulls
]
)

// Formatting

in
OData
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
let

// Application Registration Permissions needed to make this call : DeviceManagementApps.Read.All

// Microsoft Graph URL
Endpoint = "https://graph.microsoft.com/",
Version = "beta/",
Resource = "deviceAppManagement/mobileApps/",
QueryParams = "",
GraphURL = Endpoint & Version & Resource & QueryParams,

// Get an Access Token to make Graph Calls (uses Application Registration)
Bearer = #"Get-BearerToken" (TenantID, AppID, SecretID, Endpoint),

//ODataFeed to process Graph Call
OData = OData.Feed (
GraphURL,
[ Authorization = Bearer ],
[
ExcludedFromCacheKey = {"Authorization"},
ODataVersion = 4,
Implementation = "2.0"
]
)
in
OData

0 comments on commit b348c7a

Please sign in to comment.