I know this is going to be stupid and i'm kicking myself for not seeing why this is not working. But in my ELSE statement when i pipe that to a .csv i am getting blank lines.
It outputs to the console fine just nothing in the .csv file.
Thoughts ?
Function get-mdtbuiltcomputers {
param (
[string[]]$computername='localhost'
)
foreach ($comp in $computername) {
$path=Test-Path "\\$comp\c$\Windows\smsts.ini"
$connected = Test-Connection -quiet -count 2 -delay 2 -ComputerName $comp
if ($path -and $connected) {
$file=Get-ChildItem \\$comp\c$\Windows\smsts.ini
$Output = [ordered]@{'Computername'=$comp;
'MDT Image Date'=$file.creationtime
}
$obj = New-Object -TypeName psobject -Property $Output
Write-Output $obj
}
else
{
Write-Output "$comp is unavailable or not a Standard MDT Image"
}
}