I want to be able to calculate the success rate for website logins based off of information contained in a .CSV document. The problem that I am having is that I would like to get results for each website individually. Right now I can only get results for all three of the websites as a whole. Would I be able to get some help on this? Thanks again!
The .CSV file has the following information. A Date Column with a Timestamp, A Status Column that says Success or Failure, and A column that has the websites.
Reading stack overflow and other PowerShell Resources
$sites = "Site 1", "Site 2", "Site 3"
foreach ($site in $sites) {
# Total count of websites
$total = $site.Column3.Count
#Looking for websites that where sucessful based off of sucess in second column
$Sucess = $total | Where-Object { $PSItem.Status -like "*Sucess*" }
# Calculating the percent of websites
$percent = [math]::Round($failed.Count / $total.count * 100, 1)
#Going through CSV File to figure out last date of failure for wach website
$date = $failed | Select date -Last 1 | Format-Table -HideTableHeaders | Out-String
Write-Host ("{0} failed {1} % of the time on {2}" -f $site, $percent, $date)
}
I am trying to create a script with the following output as a .csv file:
• Website 1 was successfully able to connect %xx of the time the last failure date is (Date Goes here)
• Website 2 was successfully able to connect %xx of the time the last failure date is (Date Goes here)
• Website 3 was successfully able to connect %xx of the time the last failure date is (Date Goes here)
it now say:
Website 1 Succeeded 0 % of the time on
Website 2 Succeeded 0 % of the time on
Website 3 Succeeded 0 % of the time on
Aucun commentaire:
Enregistrer un commentaire