Forum Discussion
send powershell script output by email
- Nov 26, 2020
You can do something like this:
$output = @()
$licenses = Get-MsolAccountSku
foreach ($license in $licenses){
$UnusedUnits = $license.ActiveUnits - $license.ConsumedUnits
$output += "$($license.SkuPartNumber) has $unusedUnits unused licenses"
}
thank you very much for your answer wich i m sorry is not obsvious for me.
i don't see how to add it instead.
i'm trying to keep this script simple without any file insertion.
thanks for your help
You can do something like this:
$output = @()
$licenses = Get-MsolAccountSku
foreach ($license in $licenses){
$UnusedUnits = $license.ActiveUnits - $license.ConsumedUnits
$output += "$($license.SkuPartNumber) has $unusedUnits unused licenses"
}
- eli_sorowNov 26, 2020Copper Contributor
Hi,
the send-mailMessage comand doesn't like the "+" parameter in $output +=
and when i remove it , i have got the same result (only one line)
- VasilMichevNov 26, 2020MVP
You dont need to change that cmdlet, just replace the stuff I posted above.
- VasilMichevNov 26, 2020MVP
Oh wait, seems I forgot the stringify part... Replace it with
($output | Out-String)