If I understand your script correctly, you want to send an email for each pool that has more than 95% of the desktops in use ?
If yes, then the following should do this (in a very basic way).
Get-Pool|
Where {((Get-DesktopVM-Pool_id$_.pool_id).Count/$_.maximumCount) -ge0.95} |%{
Send-MailMessage-To"lucd@lucd.info"-From"lucd@lucd.info"`
-SmtpServermail.lucd.info`
-Subject"$($_.pool_id) above threshold"
}
The concept is as follows:
- get all the View pools
- filter out the ones that have more than 95% of the desktops in use
- for each of these pool execute the code block (% is an alias for the ForEach-Object cmdlet)
- in the code block send an email.
My example only places the pool_id in the Subject of the email, but you can place whatever property in the Subject or in the Body of the email.