Created
February 23, 2025 20:21
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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