Jul 7, 2008

PowerShell, Webservices & SharePoint

In this posting I'm going to show how you can generate a Webservice-Proxy on the fly in PowerShell. After that we'll use it with a SharePoint WebService. To generate the Webservice-Proxy Source Code we will use the Windows SDK Tool wsdl.exe. Then we'll compile the generated code with the .NET Framework Compiler csc.exe and load it into the PowerShell.

Let's go:

  • Create a Script. Name it "Get-WebServiceProxy.ps1"
  • First define the Path to the Tools as an Environment Variable

$env:WinSDK="$env:ProgramFiles\Microsoft SDKs\Windows\v6.0A\Bin"

$env:Net35="$env:SystemRoot\Microsoft.NET\Framework\v3.5"

  • Build a Function to generate the Proxy

#Generates a Webservice-Proxy for the specified URL

function global:Get-WebServiceProxy([String]$url=$(throw
'Parameter -url is missing!'))

{

#generate a tempfile path

$tempFileName=[System.IO.Path]::GetTempFileName()

#generate the proxy code with wsdl.exe

$null=& $env:WinSdk\wsdl.exe $url /n:Proxy /out:"$tempFileName"

#comile the code

$null=& $env:Net35\csc.exe /t:library /out:"$tempFileName.dll"
"$tempFileName"

#load the assembly

$assembly=[System.Reflection.Assembly]::LoadFrom("$tempFileName.dll")

#find the proxy within the assembly

$proxyType=$assembly.GetTypes() Where-Object { $_.IsSubclassOf([System.Web.Services.Protocols.SoapHttpClientProtocol]) –eq
$true}

#instantiate the proxy

$proxy=New-Object
–TypeName
$proxyType

#return the proxy

return
$proxy;

}

Now we will use it to get all Lists of a SharePoint Site

  • Run the Script: PS> . .\Get-WebServiceProxy.ps1
  • PS>$proxy = Get-WebServiceProxy http://localhost/_vti_bin/Lists.asmx
  • PS>$proxy.UseDefaultCredentials = $true
  • PS>$proxy.Url = http://localhost/JW/_vti_bin/Lists.asmx
  • PS>$Lists = $proxy.GetListCollection()
  • PS>$lists.List format-table -property Name, Title
  • Now you should see something like this:

Name Title

-----------------------------------------------------------------------------------------------------

{3C851AD3-C988-43C5-8BC2-4141B1960AEF} Tasks

{169C2080-59B2-480E-A2F7-FD983D7CB759} Announcements

{FB4769F3-955D-42A5-A91F-D12BA5E5CAC9} Doucments

That's all! Create as many proxies as you want...

Find more SharePoint WebServices on MSDN.

There's a better script from Oisin Grehan for using WebServices with
PowerShell:http://poshcode.org/538

24 comments:

sin wak said...

You should weight and dimensions the several delivers which might be currently being due to various web marketers so as to get the most beneficial cpm affiliation forking over in addition to true CPA circle. Seeing that this can be a well-known indicating glimpse prior to soar, thus conduct an extensive exploration prior to going prior to starting the process connected with getting started with the most beneficial internet CPA circle that can assist you to help generate income in addition to produce utmost gains for you. For just a circle connected with desktops to figure adequately, the machine really needs to be thoroughly covered in addition to was able. Even so, atlanta private investigators which the programs expertise complications like targeted visitors in addition to worms. Many computer system employees have no idea of the best way to clear up the problems. That's why many people hire this pop under ads products and services of any circle managing in addition to circle current administration application. Circle managing pertains to a head unit that gives the machine along with the circle having safety measures. This safety measures reaches to eradicating computer system worms in addition to forbids illegitimate end users by getting at this desktops along with the circle. That can minimize the risk of computer system in addition to circle complications caused by an excessive amount end user targeted visitors in addition to like. The software program is additionally geared up to help diagnose almost any electronics in addition to application improvements in addition to complete this cpm advertising ideal steps.

Anonymous said...

Progressively, a usefulness with different watches includes evolved. rolex replica All these extras ended up being one time worn out the choices look into the time frame. Nonetheless now, its breadth includes increased. replica watches But not only will be people made use of when swiss wrist watches, nonetheless are usually made use of when finishing touches to have a design and style report. cartier replica Now, being a design and style popular, it is far from more than enough if you ever just simply dress yourself in cool and trendy costumes; accessorising is critical very. cartier replica Dress yourself in Esprit different watches so that you can take a position out of the market plus generate a category for yourself. Just what exactly you might find hilarious is definitely, a brandname this started out in your sta lorry is among the list of main chosen lifestyle companies of your community now. hublot replica A enthusiasm of your leaders with Esprit encouraged the theifs to make products and solutions who were out of the ordinary sold in the market prior to now.

سما احمد said...

شركة تنظيف فلل بالدرعية
شركة تنظيف فلل بعنيزة
شركة تنظيف فلل ببريدة
شركة تنظيف فلل بالمذنب
شركة تنظيف فلل بعفيف
شركة تنظيف فلل بالغاط
شركة تنظيف فلل بثادق
شركة تنظيف فلل بالدوادمى
شركة تنظيف فلل بالمزاحمية
شركة تنظيف فلل بالقويعية
شركة تنظيف فلل بوادي الدواسر
شركة تنظيف فلل بالدلم

سما احمد said...

شركة تنظيف فلل برماح
شركة تنظيف فلل بالأفلاج
شركة تنظيف فلل بحريملاء
شركة تنظيف فلل بالزلفي
شركة تنظيف فلل بضرما
شركة تنظيف فلل بشقراء
شركة تنظيف فلل بالسليل
شركة تنظيف فلل بالقصيم
شركة تنظيف فلل بحوطة بني تميم
شركة تنظيف فلل بالحريق
شركة تنظيف فلل بالمجمعة
شركة تنظيف فلل بمرات
شركة تنظيف فلل بالرس
شركة تنظيف فلل شرق الرياض

سما احمد said...

شركة تنظيف فلل غرب الرياض
شركة تنظيف فلل شمال الرياض
شركة تنظيف فلل جنوب الرياض
شركة تنظيف فلل وسط الرياض
شركة تنظيف منازل بالدرعية
شركة تنظيف منازل بعنيزة
شركة تنظيف منازل ببريدة
شركة تنظيف منازل بالمذنب
شركة تنظيف منازل بعفيف
شركة تنظيف منازل بالغاط
شركة تنظيف منازل بثادق
شركة تنظيف منازل بالدوادمى
شركة تنظيف منازل بالمزاحمية
شركة تنظيف منازل بالقويعية

Hug Day said...

happy hug day 2016
happy hug day 2016 Date SMS Messages Quotes
Hug day Celebration Ideas
hug day sms for bf/gf

Libin Huang said...

20160426libinhollister clothing store
oakley sunglasses
michael kors handbags
tiffany outlet
ray-ban sunglasses
gucci outlet online
ray-ban sunglasses
burberry outlet online
coach outlet canada
ray-ban sunglasses
herve leger outlet
ray ban sunglasses sale
air max 90
oakley sunglasses
adidas wings shoes
michael kors outlet
michael kors factory outlet
louis vuitton bags
michael kors online outlet
nba jerseys
ralph lauren pas cher
oakley sunglasses
toms shoes
nike air max 90
nike tn pas cher
air max 90
lululemon outlet
nike air force 1
true religion outlet
michael kors outlet
burberry outlet store
ray ban sunglasses
kobe shoes
true religion outlet
discount michael kors handbags

Yuanyuan Lin said...

7.14llllllyuan"hollister shirts"
"true religion canada"
"true religion outlet"
"beats by dre"
"nike tn pas cher"
"ray ban sunglasses"
"tory burch outlet"
"mulberry handbags"
"prada outlet"
"michael kors outlet"
"tiffany outlet"
"louis vuitton neverfull"
"louis vuitton handbags"
"giuseppe zanotti shoes"
"nike uk store"
"michael kors wholesale"
"tiffany jewelry"
"michael kors outlet"
"ralph lauren pas cher"
"mulberry bags"
"nike air force 1"
"police sunglasses for men"
"gucci outlet online"
"ray ban sunglasses"
"jordan shoes"
"asics,asics israel,asics shoes,asics running shoes,asics israel,asics gel,asics running,asics gel nimbus,asics gel kayano"
"cheap jordan shoes"
"basketball shoes"
"fitflops sale"
"prada outlet online"
"ralph lauren polo"
"nike air max 90"
"omega outlet"
"lacoste shirts"
"longchamp outlet"
7.14

Justin said...

You might need to hunt down a terrible credit bike advance online and consider the Internet to be the gold mine of the Motorcycle advances. With the assistance of the Internet you will have the capacity to discover those sites which resemble web crawlers of engine cycle credits and get your fantasy Motorcycle.cash advance

Fangyaya said...

kate spade outlet
louis vuitton bags
christian louboutin shoes
kevin durant 9 shoes
ralph lauren sale
michael kors purses
coach factory outlet
polo outlet
hollister jeans
vans outlet
adidas superstar
jordan 6s
oakley sunglasses
toms outlet
cheap ray ban sunglasses
louis vuitton outlet
louis vuitton bags
louis vuitton purses
coach outlet clearance
michael kors outlet clearance
coach outlet
true religion jeans
hermes birkin handbags
oakley outlet
hermes bags
louis vuitton handbags
cartier watches outlet
michael kors outlet
kate spade outlet
polo outlet
christian louboutin outlet
ray ban sunglasses outlet
jordans for sale
louis vuitton
coach outlet online
ralph lauren outlet
mont blanc pens outlet
polo shirts
air jordan femme
vans sneakers
20168.8chenjinyan

Justin said...

Non vi è dubbio che il Viagra, la pillola blu che ha rivoluzionato il trattamento di impotenza ha avuto un profondo effetto sugli uomini che soffrono di disfunzione erettile. Ma semplicemente trovare una "soluzione rapida" per l'impotenza non superare altri problemi che possono essere state lì prima dell'inizio del trattamento. disfunzioni erettili

Justin said...

The more that you can douse up before sinking your cash into this, the higher the odds are of you making a sound speculation. Study the business sector deliberately and pose any questions early that you may have about the little's business sector arranges. payday loans carson

Justin said...

There are understudy advances offered by the government, both as financed and unsubsidized credits. These government credits typically offer an incredible rate, however frequently are too little to pay for the whole cost of proceeding with instruction, driving families to at present need to rub together whatever is left of the financing for school. payday loans chula-vista

Justin said...

Not at all like with governmentally supported advances, nobody serves as the screen on conceivable defaults, so financial specialists stress that these groups of advances are excessively dangerous over the long haul. payday loans lemon-grove

Justin said...

Private banks settle on their own loaning choices and don't need to counsel with removed credit advisory groups or stress over the security markets. Hard cash moneylenders are making arrangements and shutting advances even amidst this intense budgetary emergency. https://www.usapaydayloanstore.com/chicago

Justin said...

On the off chance that a combination credit has a lower financing cost than the numerous advances then that can bring down regularly scheduled installments, and lower the measure of enthusiasm due on the aggregate sum of the advance. payday loans

Justin said...

Not at all like government advances, these advances are credit based and require a better than average FICO assessment for endorsement. On the off chance that you don't have one, you can simply get somebody with a decent appraising to end up the co-signor and apply for the credit. aaa1autotitleloans.com/chicago

marko said...

That is the reason these organizations inspired by understudy advances to start with now have changed their range as the understudy advances are generally dangerous ventures. Large portions of these organizations have ceased their understudy credit wanders. cash advance

Paulo said...

You may know about the way that the legislatures of specific nations have begun offering credits to understudies with the assistance of which they can finish their studies. In the event that you need an understudy's advance then as a matter of first importance you have to discover the principles and controls for requesting the advance. payday loans

dada24 Xu said...

red bottoms shoes
louis vuitton bags
cheap oakley sunglasses
michael kors canada
true religion outlet store
doudoune moncler
levis outlet online
nike huarache
toms shoes outlet
ugg outlet
2016921caiyan

Meiqing Xu said...

pandora uk
true religion jeans
michael kors handbags
adidas nmd
true religion jeans
ugg australia
birkenstock shoes
michael kors canada
pandora bracelet
ray ban sunglasses
20161221caiyan

dong dong23 said...

stan smith adidas
cheap ray ban sunglasses
cheap jordan shoes
michael kors outlet
adidas outlet
hermes belt
hermes bags
nhl jerseys
michael jordan shoes
nike air max
2017.5.11chenlixiang

raybanoutlet001 said...

ferragamo outlet
polo ralph lauren outlet
ugg boots
ugg outlet
ugg boots
nike huarache
supra sneakers
cleveland cavaliers jerseys
jacksonville jaguars jersey
snapbacks wholesale

Home Improvement City of Yonkers said...

The team at Ajrin Construction Inc. is the best of the best general contractors and support staffs, as selected from within the industries over City of Yonkers NY based upon their achievements and their understanding of complex projects.Best Home Improvement Company City of Yonkers