I am seeking help to get output in csv format. I have written powershell code and would want to tweak the output to get in csv format as shown in below pic.

[![enter image description here](https://i.stack.imgur.com/Dr7Jg.png)](https://i.stack.imgur.com/Dr7Jg.png)

```
$servers = Get-Content 'C:\Temp\listofservers.txt'
foreach ($server in $servers)
{
    #DHCP
    if (((Get-Service -ComputerName $server -ServiceName 'DHCPServer' -ErrorAction SilentlyContinue).Status) -eq 'Running')
    {
        if ((((Get-DhcpServerv4Scope -ComputerName $server | Get-DhcpServerv4Lease -ComputerName $server) | Measure-Object).Count) -ge 1)
        {
            Write-Host "DHCP present on $server and in use"
        }
        else
        {
            Write-Host "DHCP present on $server and not in use"
        }
    }
    else
    {
        Write-Host("DHCP is not present on $server")
    }
    #Certificate authority
    if (((Get-Service -ComputerName $server -ServiceName 'CertSvc' -ErrorAction SilentlyContinue).Status) -eq 'Running')
    {
        Write-Host "Certificate Authority is present on $server"
    }
    else
    {
        Write-Host "Certificate Authority is not present on $server"
    }
}

```