Validate Status Column using powershell. If any status column contain Not-compliant then overall status column needs to be displayed not-compliant. Attached data for your reference.
Trying below code but not getting expected output.
$csv = Import-Csv -Path C:\Users\Desktop\DDPC1.csv
$csv | ForEach-Object {
if ($_.Status -eq "Not-Compliant") {
Echo "The system is $($_.Status) in $($_.Parameter)"
}else
{Write-Host "System is Fully compliant in All Parameter"
}
}
In Case of multiple parameter non-compliant, output needs to be The system is Not-Compliant in Patching and GoogleChrome. But Getting below output.
System is Fully compliant in All Parameter
The system is Not-Compliant in Patching
The system is Not-Compliant in Chrome
System is Fully compliant in All Parameter
In Case of compliant, output needs to be The system is Fully Compliant in all parameter. But Getting below output.
System is Fully compliant in All Parameter
System is Fully compliant in All Parameter
System is Fully compliant in All Parameter
System is Fully compliant in All Parameter
CSV Data: -
Parameter | Version | Status |
---|---|---|
Windows 11 | 20H2 | Compliant |
Patching | NA | Not-Compliant |
Chrome | 10.1 | Not-Compliant |
Overall | NA |