could do with some help please, below is some code that goes through all the servers in a list and reports on their disk space but the output is in the wrong format. I want o have each disk on their own line and then highlight those that are over 90% in red… Pease help.
Wow … my eyes hurt … … could you please reformat your post and format the code properly as code (described here: Read Me Before Posting! You’ll be Glad You Did!) … AND try to avoid posting that much white space.
What’s wrong with the output? At first glance, it looks like it will create what you’re asking for… Can you provide a scrubbed example of the raw HTML that is generated?
Hi Richard
Could I recommend you the “ConvertTo-Html” cmdlet? I would normally write like below for any basic Html output. it is a lot cleaner and readable.
$Head = @"
Put your style tag here.
"@
ConvertTo-Html -Head $Head -Body $YourBodyTable -Title "Your Title" | Out-File $OutputFile
Thank you for your help so far, as mentioned by Olaf i am trying to get the results that equal or greater than highlighted in red so would need to be HTML.
The main issue is that the output is listing all possible drives for each server in one line as opposed to each drive on a new line. A screen shot of the output can be found here.
I hadn’t even picked up on the fact that the cells weren’t highlights good find… Is till have the issue where all the drives are bunched into one though and i really would have liked for the to be a drive per line… as shown below - thank you for picking up on that though Charles.
I noticed some things that would be causing the issues:
Get-DiskSpace isn't really doing anything, and if it was supposed to, you would need to make it an advanced function for it to be more useful. It can be removed completely.
Each row is returning the entire collection rather than just one object per row. For instance, the $Result += New-Object ... in the Foreach ($drive in $drives){...}, you're referencing $disk.driveletter (and so on) where $disk is the collection, not an individual disk object. You need to reference the $drive instead.
Just assign the foreach to $Result instead of concatenating objects ($Result += New-Object).
Change the foreach ($ServerName in $ServerList) to this: