Skip to content

Instantly share code, notes, and snippets.

@davejlong
Created February 23, 2025 20:21
Show Gist options
  • Save davejlong/6a460dbbe3c739cc5cb5ffa22192568d to your computer and use it in GitHub Desktop.
Save davejlong/6a460dbbe3c739cc5cb5ffa22192568d to your computer and use it in GitHub Desktop.
Get a count of assets counts for each customer based on a saved search ID
# Get assets matching saved search id 38744
$Assets = Get-SyncroAsset -AssetSearchId 38744
# Create an empty object to store the reduced counts
$Companies = @{}
# Loop through the assets
foreach ($Asset in $Assets) {
# Increment the count for the customer
$Companies[$Asset.customer.business_name] += 1
}
# Output the companies
$companies
##########
# Output
##########
Name Value
---- -----
Customer 1 35
Contoso, Inc. 21
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment