- <#
- .SYNOPSIS
- Gets stock quotes using a web servoice
- .DESCRIPTION
- This function uses the New-WebServiceProxy cmdlet to
- create a web service proxy. Then it calls that proxy
- to get stock information.
- .NOTES
- File Name : get-stockquote.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Original post:
- http://PoshCode.org/embed/752
- Updated script posted:
- http://www.pshscripts.blogspot.com
- .INPUTTYPE
- String(s) representing stock tickers to find
- .RETURNVALUE
- XML Element, holding stock details
- .EXAMPLE
- Run from PowerShell Prompt:
- Get-StockQuote "MSFT"
- Output - left as an exercise for the reader
- .EXAMPLE
- Run from Pipeline
- "IBM","INTC" | Get-StockQuote
- Output - left as an exercise for the reader
- .PARAMETER TICKER
- A string, or array of strings representing stock tickers
- The function gets stock details for each stock ticker provided
- #>
- function Get-StockQuote {
- param(
- [Parameter(Position=0, Mandatory=$FALSE, ValueFromPipeline=$TRUE)]
- [String] $TICKER="MSFT" )
- process {
- $ticker
- $s = new-webserviceproxy -uri http://www.webservicex.net/stockquote.asmx
- foreach ($symbol in $ticker) {
- $result = [xml]$s.GetQuote($symbol)
- $result.StockQuotes.Stock
- } # end foreach
- } #end process block
- } # end function
- "Example 1:"
- "=========="
- Get-StockQuote MSFT
- ""
- "Example 2:"
- "=========="
- "IBM","INTC" | Get-StockQuote
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Showing posts with label web service. Show all posts
Showing posts with label web service. Show all posts
Tuesday, 30 December 2008
Get-StockQuote.ps1
Monday, 29 December 2008
Validate-EmailAddress.ps1
- <#
- .SYNOPSIS
- Validates an email address using a web service
- .DESCRIPTION
- This script uses the New-WebServiceProxy cmdlet to
- create a web service proxy. Then it calls that proxy
- to Validate an email address.
- .NOTES
- File Name : validate-emailaddress.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Script posted to:
- http://www.pshscripts.blogspot.com
- .INPUTTYPE
- String(s) representing email address to validate
- .RETURNVALUE
- [Boolean] - whether email address was valid
- .EXAMPLE
- Run from PowerShell Prompt:
- PS C:\foo> .\Validate-EmailAddress "tfl@psp.co.uk”
- True
- .EXAMPLE
- Run from Pipeline:
- PS C:\foo> "tfl@psp.co.uk", "foo@foo.bar" | .\Validate-EmailAddress
- True
- False
- .PARAMETER addr
- A string, or array of strings representing email addresses to check
- #>
- param(
- [Parameter(Position=0, Mandatory=$FALSE, ValueFromPipeline=$TRUE)]
- [String] $Addr = "doctordns@gmail.com" )
- process {
- $s = new-webserviceproxy -uri http://www.webservicex.net/validateEmail.asmx
- foreach ($a in $addr) {
- $result = $s.IsValidEmail($a)
- $result
- } # end foreach
- } #end process block
Labels:
powershell,
PowerShell scripts,
PowerShell V2,
Script,
scripts,
web service
Subscribe to:
Posts (Atom)