My aim is to send an automated message which contains all the strings from my loop.
I got a $body variable which is something like
This message shows you how much
$sizeof your$projectis used
I want to merge these strings into one variable which I can send through mail, but either it sends in separated mails or only the last loop remains.
Code:
Enter-PSSession *computer*
$attributes = (Get-FsrmQuota | select Description, Size, PeakUsage)
foreach ($attribute in $attributes)
{
$counter = $attributes.Count
$descr = $attribute.Description
$size = $attribute.size
$tomb = @($descr.Split(";"))
$mail = $tomb["1"] # user mail adress
$project = $tomb["0"] # user project
$name = $mail.Split("@")[0] #username
$firstName = $name.Split(".")[0]
$lastName = $name.Split(".")[1]
$size = [Math]::Round(($attribute.Size)/1Gb,1).ToString() + " Gb" #storage size
$usage = [Math]::Round(($attribute.Usage)/1Gb,1).ToString() + " Gb" #storage usage
$percent = [Math]::Round((($attribute.Usage / $attribute.Size)*100),2).ToString() + "%"
$projname = $array["2"] #project name
for($i=1; $i -le $counter; $i++)
{
$ITBody = "The $projname project uses $size."
$array+=$ITBody
}
}
write-host $array
Got the results duplicated soo many times
forloop?