Weather For Usa From Webservice


Skip to comments

This is how I am now pulling simple weather data in EZ-Builder.

If you are willing to create a powershell script and batch file, there is an easy way to pull the local weather from a Web Services based on USA zipcodes. This web services does not work outside the US. But other countries might have similar web services where a similar method could be used.

For those that don't know a web services is a way to interact with a database or dataset via an http website. It's formatted a special way to return variables and you query most web services like a database.

1. You have to create a power shell script using PowerShell ISE. All versions of Windows from 7 and up should have power shell installed already, if not you can download it from doing a search for Windows PowerShell from the Microsoft website.

Enter this in PowerShell:


#This removes the old temperature weather .txt
Remove-Item "C:\Users\weyou_000\Documents\EZ-Builder\My Projects\PowerShell\CurrentTemperatureMonroe.txt" -ErrorAction SilentlyContinue

#This pulls the local Weather based on zipcode. This only works for the United States, other countries might have different webservices.
#My zip code is 45050, you should need to update the zip code to reflect yours
$uri = "";
$WeatherForecast = New-WebServiceProxy -uri $uri -UseDefaultCredential -namespace "WeatherForecast"
#$WeatherForecast.GetCityWeatherByZIP(45050).details #This line is used if you want to see all avaliable items from this web service

$Condition = $WeatherForecast.GetCityWeatherByZIP(45050).Description
$CurrentTempature = $WeatherForecast.GetCityWeatherByZIP(45050).Temperature

#This writes the temperature and condition of the local weather to a text file
Write-Output $CurrentTempature $Condition | Out-File -FilePath "C:\Users\weyou_000\Documents\EZ-Builder\My Projects\PowerShell\CurrentTemperatureMonroe.txt"

This script deletes the .txt file where current weather data is written (if the file is there), then is makes a web service call to the website and pulls the data. Variables within the script are assigned for temperature and condition and these variables are written to the text file.

You will need to change the location path of the txt file to reflect the file local and name you want to use. You'll also need to change the "45050" zip code to reflect your own.

2. Next you'll need to make a batch file. A batch file is an old school PC script method to automate file functions. In the case, we are using a batch file to run the PowerShell script.

Enter this in the Batch file:


powershell -ExecutionPolicy RemoteSigned -File "C:\Users\weyou_000\Documents\EZ-Builder\My Projects\PowerShell\CurrentTempMonroe.ps1"

Again, change the path and file name to reflect your own. Make sure your batch file ends with .bat. You can create a batch file by opening notepad, and saving the file as, all files and end the file name with .bat.

3. Test your batch file. If you double click on it, it should run and you should see a new .txt file created from the path/file name you defined in the PowerShell script. If text files should have two lines, one for the temperature and one for the weather condition. If you don't have this text file or data in the file, re-check the previous steps.

4. Create a script in ARC to run the batch file, pause, then read the text file with the temperature data in it.

Enter this in ARC script:


#This will return the local Monroe,OH temperature and weather condition
#This script calls a batch file and the batch file calls a powershell script
#You must have the batch file and the powershell file configured to use this

Exec("C:\Users\weyou_000\Documents\EZ-Builder\My Projects\BatchFiles\CurrentTempMonroe.bat")


$filename = "C:\Users\weyou_000\Documents\EZ-Builder\My Projects\PowerShell\CurrentTemperatureMonroe.txt"

if (FileExists($filename) = false)
print("File does not exist")

$MonroeCurrentTemperature = FileReadLine($filename)
$MonroeCurrentCondition = FileReadLine($filename)

FileReadClose("C:\Users\weyou_000\Documents\EZ-Builder\My Projects\PowerShell\CurrentTemperatureMonroe.txt")

print("Monroe Current Temp: " + $MonroeCurrentTemperature)
Say("Current Monroe Ohio Temperature is " + $MonroeCurrentTemperature)
print("Monroe Current Condition: " + $MonroeCurrentCondition)
Say("and weather condition is " + $MonroeCurrentCondition)

This is my script. You'll need to change the paths of the text file and batch job and you should rename the variables to reflect the name of your local city in the US.

You can repeat this method to pull weather data for multiple US cities.

By — Last update
Hello Justin,

Looks interesting ! I went to the cdyne website as referenced in your shell script but I don't see anything regarding weather. Also it looks like one has to pay for this service? What is the actual site that is used to access the weather information and is there a way to access it to enter in the zipcodes manually to see the weather information? would we use this same web url to access weather in all cases no matter where we are in the US? This would be a great application to have as once we have the weather information it would be fairly easy to have the robot speak the data. If you could clarify the site you reference in the url that would be great. I'm not familiar with powershell script programming, but looks pretty straightforward. I am familiar with batch files, however I would need to go over some of my reference materials from the past. Thanks for your help !Rick B.:)

Is the first block of code above the actual powershell script or is it an EZB Script. Looks like an EZB Script? If not could you post the powershell script that you created for this application? Seems it should be pretty much the same for all users of this application? Thanks Again....Rick B. :)
Nothing to sign up for. You can manually go to

Then click get GetCityWeatherByZip and enter in a US zipcode.

1st Script is PowerShell, 2nd is the Batch code, 3rd is the ARC script.

If you need a intro for PowerShell and batch scripts a search on YouTube will yield some helpful videos.

If you're not comfortable with PS, it might not be right for you. I just share how I use it incase others want to copy it.

Thanks for your clarification. Looks like you have pretty much done everything for the user. Looks like we just need to modify powershell script for our individual locations. I will give it a go. Thanks again.....Rick B.