Last active
February 19, 2024 16:17
-
-
Save lwsrbrts/d96092b65f2f7b7952e2f7983a9ee527 to your computer and use it in GitHub Desktop.
Used to obtain the average natural gas calorific value for UK North West region from a set date to now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$TodayDate = Get-Date -Format "yyyy-MM-dd" | |
$PreviousReading = Read-Host -Prompt 'Enter the date of the previous reading in dd/mm/yyyy format' | |
$PreviousReadingDate = Get-Date $PreviousReading -Format "yyyy-MM-dd" | |
$Soap = @" | |
<?xml version="1.0" encoding="utf-8"?> | |
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> | |
<soap12:Body> | |
<GetPublicationDataWM xmlns="http://www.NationalGrid.com/MIPI/"> | |
<reqObject> | |
<LatestFlag>Latest</LatestFlag> | |
<ApplicableForFlag>ApplicableFor</ApplicableForFlag> | |
<FromDate>$($PreviousReadingDate)T00:00:00.000Z</FromDate> | |
<ToDate>$($TodayDate)T00:00:00.000Z</ToDate> | |
<DateType>GASDAY</DateType> | |
<PublicationObjectNameList> | |
<string>Calorific Value, LDZ(NW)</string> | |
</PublicationObjectNameList> | |
</reqObject> | |
</GetPublicationDataWM> | |
</soap12:Body> | |
</soap12:Envelope> | |
"@ | |
$Req = Invoke-WebRequest -Uri "http://mip-prodpull-api.azurewebsites.net/MIPIws-public/Public/PublicWebService.asmx" -Method 'Post' -ContentType 'application/soap+xml' -Body $Soap | |
#Set-Content -Path D:\test.xml -Value $Req.Content # If you'd like to save the output to disk? | |
[xml]$XML = $Req | |
$Value = $XML.Envelope.Body.GetPublicationDataWMResponse.GetPublicationDataWMResult.CLSMIPIPublicationObjectBE.PublicationObjectData.CLSPublicationObjectDataBE.Value | Measure-Object -Average | |
$Value.Average | |
[math]::Round($Value.Average, 4) | |
#OR | |
"{0:N2}" -f $Value.Average |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍🏻