-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Hi!
The script to collect the inventory is great!.
One suggestion, that I applied and is was much faster, specially if the device list is to big.
Instead of sending one app to log analytics at a time, send the collection of apps of one device. This is the code modification that I did
$totalDevices | ForEach-Object {
$deviceManufacturer = $.Manufacturer
$deviceOs = $.OperatingSystem
$UserUpn = $.EmailAddress
$body = @()
$device.detectedApps | ForEach-Object {
$properties = [Ordered] @{
"UserUPN" = $UserUpn
"Hostname" = $deviceHostname
"Manufacturer" = $deviceManufacturer
"Model" = $deviceModel
"OperatingSystem" = $deviceOs
"OSVersion" = $deviceOsVersion
"AppName" = $.DisplayName
"AppVersion" = $_.Version
}
$body += $properties
}
$sdeviceAppInventory = $body | ConvertTo-Json
$params = @{
f_customerId = $customerId
f_sharedKey = $sharedKey
f_body = ([System.Text.Encoding]::UTF8.GetBytes($sdeviceAppInventory))
f_logType = $logType
}
$logResponse = Post-LogAnalyticsData @params
"Working on device {0} - {1}/{2}....Apps:{3}....Response {4}" -f $deviceHostname, $counter, $totalDevices.count,
$device.detectedApps.count, $logResponse
$counter++
}
That will send per device one call to log analytics instead of 1 call per app. is much faster.
Thanks!