hi there I am recently starting to work with PowerShell and I have some issue with the following script can you please help me to fix it I need to print in 1 row the state of the drive and if the memory is bellow 20%
$Computers = Get-Content -Path C:\Users\gbekari\unbackup\Servers.txt
Foreach ($Computer in $Computers)
{
Get-WmiObject Win32_Volume -Filter "DriveType='3'" -ComputerName $Computer | ForEach {
New-Object PSObject -Property @{
#Where-Object { $_.DriveType -eq "3" } # Select-Object SystemName,VolumeName,DeviceID
Computername = $computername
date = (Get-Date -format "dd.MM.yy HH:mm")
size = $_.Size/1GB
freeSpace = ([Math]::Round($_.FreeSpace /1GB,2))
Status = if ([Math]::Round($_.FreeSpace /1GB,2) -contains -19) {'Warning'} else {'NONE'}
empty = "Diskcheck"
}
}
}|ConvertTo-Csv -NoTypeInformation -Delimiter "|" | % {$_-replace'"',''} | Select-Object -skip 1 | Out-File -FilePath Get-Content -Path C:\Users\gbekari\unbackup\Sers.txt -Encoding ascii