Hi,
The output of Write-Host cannot be redirected. You could use the Export-Csv cmdlet to create the CSV file.
$Device = $env:computername #this is device
$OS = (Get-WMIObject win32_operatingsystem).Caption #this is OS
$ABNIP = $AP | ForEach-Object {
if ($IP -notcontains $_) { $_ }
}
$NABIP = $IP | ForEach-Object {
if ($AP -notcontains $_) { $_ }
}
[PSCustomObject]@{
"Device" = $Device
"OS" = $OS
"ABNIP" = $ABNIP -join ","
"NABIP" = $NABIP -join ","
} | Export-Csv -Path C:\temp\out.csv -NoTypeInformation
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.