Combining output powershell into csv and html

I have these three commands here that works well with the output.What I would like to do is combine all three of these in one script and have the out put to come out in a csv and also a html with the following



#First command
get-mailbox -resultsize:unlimited | foreach { ($_.emailaddresses -like "smtp:*").Count -gt 1 -and $_.primarysmtpaddress -match '^[\W]' -or } | Select Displayname, emailaddress, alias

Open in new window


#Second command
get-mailbox | foreach {$_.recipienttypedetails -like "shared*"} | Select Displayname, emailaddress, alias

Open in new window


#Third Command
get-mailbox -resultsize:unlimited | where {$_.displayname -notmatch '^[\W]' } | Select Displayname, emailaddress, alias

Open in new window





Here are the results for the first command
 
      Displayname, emailaddress, alias
      Displayname, emailaddress, alias
      Displayname, emailaddress, alias



      Here are the results for the second command


      Displayname, emailaddress, alias
      Displayname, emailaddress, alias
      Displayname, emailaddress, alias


      Here are the results for the third command

      Displayname, emailaddress, alias
      Displayname, emailaddress, alias
      Displayname, emailaddress, alias
techdriveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPRetiredCommented:
$output=@()
$var1 = get-mailbox -resultsize:unlimited | foreach { ($_.emailaddresses -like "smtp:*").Count -gt 1 -and $_.primarysmtpaddress -match '^[\W]' } | Select Displayname, emailaddress, alias
$output += $var1
$var2 = get-mailbox | foreach {$_.recipienttypedetails -like "shared*"} | Select Displayname, emailaddress, alias
$output += $var2
$var3 = get-mailbox -resultsize:unlimited | where {$_.displayname -notmatch '^[\W]' } | Select Displayname, emailaddress, alias
$output += $var3
$output
# $output | format-list
#$output | ConvertTo-Html -Body | Out-File -FilePath c:\test\output.html
#

Open in new window

you can pipe any of the $var?'s or $output to whatever
Quibble: putting everything on one line makes it hard to debug and maintain. It doesn't cost anything to split into separate lines and format accordingly.

The first get-mailbox had a hanging -or after the -match

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.