Need help exporting to CSV

I have this bit of script and I am trying to get the results output to a CSV.

$time = (Get-Date).Adddays(-5)

$vm = (Get-ADComputer -Filter { OperatingSystem -Like ‘Windows Server’-and LastLogonTimeStamp -gt $time } | Where-Object {$_.distinguishedname -notmatch “OU=Domain Controllers”} | Select-Object -ExpandProperty Name)

Invoke-Command -ComputerName $vm -ScriptBlock {
$reg = REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA
$hostname = hostname
write-host $hostname $reg
}

Any ideas?

Any ideas on outputting results to CSV? What is the issue you’re having? I don’t see any attempts to export to csv so not sure what you are asking. Check out the help topics for ideas.

Get-Help Export-CSV

Get-Help *csv*

Get-Help Export-CSV -Full