hackoo

Covid-19_Infos.ps1

Aug 3rd, 2021
1,422
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  cls
  2.  $Restparam = @{
  3.      'uri' = "https://disease.sh/v3/covid-19/countries"
  4.       Method = 'Get'
  5.  }
  6.  $Countries_Array = @()
  7.  $Data = Invoke-RestMethod @restparam
  8.  $Country = $Data.country
  9.  # Fill our array with all Countries
  10.  # Append into array
  11.  $Countries_Array += $Country
  12.  Function get-epochDate ($epochDate) { [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddMilliseconds($epochDate)) }
  13.  Foreach($Country in $Countries_Array) {
  14.  $Restparam = @{
  15.      'uri' = "https://disease.sh/v3/covid-19/countries/$Country"
  16.       Method = 'Get'
  17.  }
  18.  Try {
  19.      $Data = Invoke-RestMethod @restparam
  20.      $Updated = get-epochDate $Data.updated
  21.      $Country = $Data.country
  22.      $Cases = $Data.cases
  23.      $Deaths = $Data.deaths
  24.      $Recoverd = $Data.recovered
  25.      $flag = $Data.countryInfo.flag
  26.      $Active = $Data.active
  27.      $Tests = $Data.tests
  28.      $Critical = $Data.critical
  29.      echo "$Country"
  30.      echo "$Updated"
  31.      echo "--------------------"
  32.      echo "$Tests Tests"
  33.      echo "$Cases Total Cases"
  34.      echo "$Active Actives"
  35.      echo "$Deaths Deaths"
  36.      echo "$critical Criticals"
  37.      echo "$Recoverd Recoverd"
  38.      #$flag
  39.      echo "--------------------"
  40.      }
  41.      Catch
  42.      {
  43.          Write-Host "`r`n$Country" -ForegroundColor Yellow -BackgroundColor Black
  44.          Write-Host "Message: [$($_.Exception.Message)]`r`n" -ForegroundColor Red -BackgroundColor Black
  45.      }
  46.  }
RAW Paste Data