# Powershell output html email help

**URL:** <https://forums.powershell.org/t/powershell-output-html-email-help/11213>\
**Category:** Pester\
**Created:** [August 27, 2018, 4:50pm UTC](https://forums.powershell.org/t/powershell-output-html-email-help/11213 "2018-08-27T16:50:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwicked](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jwicked](https://forums.powershell.org/u/jwicked)\
**Post date:** [August 27, 2018, 4:50pm UTC](https://forums.powershell.org/t/powershell-output-html-email-help/11213/1 "2018-08-27T16:50:33Z")

</div>

Hi,

Im a noobie with Powershell, please go easy on me. The help desk or systems team forgets to move the newly created workstation or servers from the COMPUTERS OU into their respective OUs.

The goal is to create a powershell script that pulls a list of computer objects, along with their Operating System. Also, For computer objects running a server operating system (i.e. Windows Server 2008/2012, etc), email that list to the systems team and non server machines to the helpdesk email.

I only found a way to output these results via csv, but not html or export the html to email. Any help master powershell writers? e-books, links. Thanks for reading.

Get-ADComputer -Filter {(OperatingSystem -notlike “_Windows XP Professional_”) -and (OperatingSystem -notlike “_Windows 7_”) -and (OperatingSystem -notlike “_Windows 10 Pro_”) -and (OperatingSystem -notlike “_Windows 10 Enterprise_”) -and (OperatingSystem -notlike “_MAC_”)} -SearchBase “CN=null,DC=null,DC=null” -Properties Name,OperatingSystem,Description | Select Name,OperatingSystem,Description |Sort-Object -Property OperatingSystem -Descending | Export-Csv C:\Servers\_OU\_Info.csv -NoTypeInformation -Encoding UTF8

---

<div class="post-metadata">

**Author:** ![postanote](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@postanote](https://forums.powershell.org/u/postanote)\
**Post date:** [August 27, 2018, 7:42pm UTC](https://forums.powershell.org/t/powershell-output-html-email-help/11213/2 "2018-08-27T19:42:46Z")

</div>

Since you are new to PS. It’s really important that you get some edification to solidify your basics.

Visit Microsfot Virtual Academy, Microsoft MSDN Channel9 and YouTube, search for Beginning PowerShell, or just PowerShell to get to the video training / education.

As for your post, please use the code formatting tools so that it’s easier of folks willing help you.

Also, don’t make a habit of trying to squeeze everything in to one line. One liners are good for adhoc stuff, but not for shared scripts or PS apps. It makes the hard to read, debug, support and maintain.

Be sure to use resources that already exist …

> 'powershellgallery.com'

... before struggling to write from scratch. Know that Windows Server 2012 using the ADAC will write PS code for you that you can tweak as well.

You say you want HTML\< but you are not using the HTML cmdlets.

```
Get-Command -Name '*html*' | Format-Table -AutoSize
```

If all you want to work on are servers, then only ask for them…

Get-ADComputer -Filter {OperatingSystem -Like ‘_Server_’}

If all you want is clients then…

Get-ADComputer -Filter {OperatingSystem -NotLike ‘_Server_’}

So, something like this…

```
Get-ADComputer -Filter "OperatingSystem -Notlike '*Server*'" -Properties Name,OperatingSystem,Description | 
Select Name,OperatingSystem,Description | 
Sort-Object -Property OperatingSystem -Descending | 
ConvertTo-Html | Out-File 'c:\temp\Servers_OU_Info.html'
Invoke-item 'c:\temp\Servers_OU_Info.html'
```

Then just use Send-MailMessage to send this to whomever.

---

<div class="post-metadata">

**Author:** ![postanote](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@postanote](https://forums.powershell.org/u/postanote)\
**Post date:** [August 27, 2018, 7:53pm UTC](https://forums.powershell.org/t/powershell-output-html-email-help/11213/3 "2018-08-27T19:53:53Z")

</div>

For whatever reasons, my post got locked and I cannot update / modify / cleanup my post, so there’s that.

I am not sure why that footer was added. I did not do that.

But I can edit this one as needed. Hummmm….

---

<div class="post-metadata">

**Author:** ![jwicked](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jwicked](https://forums.powershell.org/u/jwicked)\
**Post date:** [August 27, 2018, 8:10pm UTC](https://forums.powershell.org/t/powershell-output-html-email-help/11213/4 "2018-08-27T20:10:05Z")

</div>

Thank you!! I wasnt sure where to begin. Thanks again for all your help and guidance.

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [August 28, 2018, 12:01am UTC](https://forums.powershell.org/t/powershell-output-html-email-help/11213/5 "2018-08-28T00:01:48Z")

</div>

@Postanote, Myself faced same issue(reply came along with footer and not able to edit it). Just updated it in Web Site Feedback & Assistance forum.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:13pm UTC](https://forums.powershell.org/t/powershell-output-html-email-help/11213/6 "2024-05-16T21:13:24Z")

</div>

Closed on May 16, 2024, 9:13pm UTC


