I'm going to assume that when you say you want "easier to read" output, you mean want easier to read output on the console, and not in that CSV file. Because CSV files are not meant to be pretty or easy for humans to read - CSV files are meant to be easy for computers to process.
So to that end, I've just ignored the Export-CSV cmdlet at the end. In my opinion, getting nice console output and getting efficient CSV data are two totally separate goals.
When I run your script, the output looks like this:
User ComputerName Domain LastUsed
---- ------------ ------ --------
Ryan SERVER1 SERVER1 9/25/2014 11:53:54 PM
NETWORK SERVICE SERVER1 NT AUTHORITY 9/25/2014 11:53:54 PM
LOCAL SERVICE SERVER1 NT AUTHORITY 9/25/2014 11:53:54 PM
SYSTEM SERVER1 NT AUTHORITY 9/25/2014 11:53:54 PM
Ryan SERVER2 SERVER2 9/25/2014 11:53:54 PM
NETWORK SERVICE SERVER2 NT AUTHORITY 9/25/2014 11:53:54 PM
LOCAL SERVICE SERVER2 NT AUTHORITY 9/25/2014 11:53:54 PM
SYSTEM SERVER2 NT AUTHORITY 9/25/2014 11:53:54 PM
I see what you mean about the console not separating out or putting any "gap" between each computer.
So I made some modifications to your script:
:NextComputer Foreach ($Computer In "localhost", "localhost")
{
Write-Host " " -ForegroundColor Green -BackgroundColor Black
Write-Host " Massive Flashy Header For $Computer! " -ForegroundColor Green -BackgroundColor Black
Try
{
$Profiles = Get-WMIObject -ClassName Win32_UserProfile -ComputerName $Computer -ErrorAction Stop
}
Catch
{
Write-Error "Error while getting user profiles from $Computer`: $($_.Exception.Message)"
Continue NextComputer
}
Write-Host " User profiles found: $($Profiles.Count) " -ForegroundColor Green -BackgroundColor Black
If ($Profiles.Count -LT 1)
{
Continue NextComputer
}
$ProfileCollection = @()
:NextProfile Foreach ($Profile In $Profiles)
{
$UserInfo = [WMI] ($Profile.__PATH -Replace "Win32_UserProfile", "Win32_SID")
$ProfileCollection += New-Object PsObject -Property @{
ComputerName = $Computer
Domain = $UserInfo.ReferencedDomainName
User = $UserInfo.AccountName
LastUsed = $Profile.ConvertToDatetime($Profile.LastUseTime)
}
}
$ProfileCollection | Format-Table -AutoSize
}
And now the output looks a little more readable, since the results from each computer are now separated from one another:
Massive Flashy Header For SERVER1!
User profiles found: 4
User ComputerName Domain LastUsed
---- ------------ ------ --------
Ryan SERVER1 SERVER1 9/25/2014 11:56:50 PM
NETWORK SERVICE SERVER1 NT AUTHORITY 9/25/2014 11:56:50 PM
LOCAL SERVICE SERVER1 NT AUTHORITY 9/25/2014 11:56:50 PM
SYSTEM SERVER1 NT AUTHORITY 9/25/2014 11:56:50 PM
Massive Flashy Header For SERVER2!
User profiles found: 4
User ComputerName Domain LastUsed
---- ------------ ------ --------
Ryan SERVER2 SERVER2 9/25/2014 11:56:50 PM
NETWORK SERVICE SERVER2 NT AUTHORITY 9/25/2014 11:56:50 PM
LOCAL SERVICE SERVER2 NT AUTHORITY 9/25/2014 11:56:50 PM
SYSTEM SERVER2 NT AUTHORITY 9/25/2014 11:56:50 PM
More to your liking, yes?