Webservices from Powershell without WDSL.exe

I use Powershell to automate Sharepoint tasks quite offen. There are however some caveats about this, mainly that you have to be on the same machine as the machine you want to use as a target for the script. To solve this you can use the webservices available in Sharepoint, and I have been using this for quite some time. The only problem is that the most common method “out there” requires wdsl.exe which is a part of the .net sdk.

Today I stumbled upon a article by Lee Holmes who have constructed a method for generating the wdsl without wdsl.exe in pure powershell. This have been published for a while but usefull anyways =) I’ve also included it my spps-toolkit.ps1. Here’s the link: http://www.leeholmes.com/blog/CallingAWebserviceFromPowerShell.aspx

Common answer about diacritics

One question I offen get when delivering training for Sharepoint is about how the Sharepoint system treats our nordic charachters, such as ÅÄÖ. This is breif explanation about the problem and solution.

Problem
There is none of the setups, discs or whatever (even the nordic ones) where diacritics senitivity is turned on by default. This means that the search engine in Sharepoint treats our extra characters as accents instead of real chachters. As a Example Å is treated as accented A and Ä is also treated as a accented A. Which means that sortorders etc is not working correctly, and that search results will not match as expected.

Solution
We must tell the system that we wish to be siacritics sensitive. This is not done by GUI (CentralAdmin) but rather out trusted little helper STSADM.

The following command will deliver just that functionality:
Stsadm -o osearchdiacriticsensitive -setstatus TRUE

Also, you must rebuild the index for this to work. Se more information about the command at technet.

ShareCheck – FileSystem to SharePoint migration headache reduction.

The problems of Sharepoint not accepting all chars in filenames (&{} etc..) sometimes brings problems when you need to migrate a large number of files from filesystem. I have not yet found any program which can be batched to make this work easy. I have found SharePrep (http://www.purgeie.com/shareprep/) but I see two problems with this software: 1) it’s not freeware, 2) its not batchable (command-line). This is why I started to make ShareCheck.

The ShareCheck will traverse a directory structure and rename files which have chars not allowed by sharepoint. The program have a built-in conversion table, but you are also able to specify a external XML-file for denfinition of the conversion rules, which in turn mean that this app can be for other purposes as well. When executed the program will output a XML output which could be piped or redirected to se the results (human readable output is also availiable).

Usage of ShareCheck.exe, commandline arguments:
-path=”g:\pathtomigrate”: Specifies the path to files to process, if ommited current directory will be used.
-config=”c:\config.xml”: Specified the alternative config (se example-config.xml for defaults used when nothing specified)
-norecurse: Do not recurse subdirectories, only process the starting directory
-legacyoutput: Do not output XML, but rather a HR-text (Human Readable Text)
-whatif: Do not actualy rename the files, but just simulate what would be done

Default configuration XML (built-in and used if none is specified):
<sharecheck> (root element)
  <filechecks> (all file checks collected here)
    <startwith match=”.” replace=”” /> (startwith is to check if a specific file starts with something and replace it)
    <startwith match=” ” replace=”” />
    <filename match=”#” replace=”_” /> (filename checks the filename for the occurance anywhere and replaces)
    <filename match=”&amp;” replace=”_” />
    <filename match=”&quot;” replace=”_” />
    <filename match=”%” replace=”_” />
    <filename match=”:” replace=”_” />
    <filename match=”*” replace=”_” />
    <filename match=”&lt;” replace=”_” />
    <filename match=”&gt;” replace=”_” />
    <filename match=”?” replace=”_” />
    <filename match=”\” replace=”_” />
    <filename match=”{” replace=”_” />
    <filename match=”}” replace=”_” />
    <filename match=”~” replace=”_” />
    <filename match=”|” replace=”_” />
    <filename match=”/” replace=”_” />
  </filechecks>
</sharecheck>

Still to-do:
* Check for long directory names as well
* Actualy implement -norecursion (it’s currently broken)

Thinking of…
* Replace -whatif with -commit to always run in testmode unless specified??
* Other suggestions??

The executable are compilled for x32 and x64, its built in C# and uses .NET 3.5. The software is somewhat beta which means that you should test it before you use it in a real enviroment. No warranties, expressed or otherwise, at all – use on your own risk! The software is free, you may distribute it as you wish but please keep my info in it. Download it here.