Wednesday, December 24, 2014

Merry Christmas

Merry Christmas and happy new year


Thursday, December 18, 2014

Export property bag to a cvs file

Just a simple script, that read the property bag from a web, converts the key/value to a PowerShell object and pipe it to the Export-csv cmdlet.

$path = "c:\temp\propertybag.cvs"
$url = "http://win-l2sfc3oetnn"
$web = get-spweb $url
$web.AllProperties.getenumerator() | % {new-object psobject -Property @{Key = $;Value=$_.value} } | export-csv $path -notype -Delimiter ";"

Thursday, December 11, 2014

PowerShell and delegates

At my current project, we have written a lot of PowerShell. We came to discuss whether, we can use delegates in PowerShell or it is a pure C# (.net) thing. The short answer is yes, you can do it. The syntax is like this:

1 $url = "http://win-l2sfc3oetnn"
2 function GetSiteElevatedPrivileges
3 {
4 $site = new-object "Microsoft.SharePoint.SPSite" $url
5 write-host $site.RootWeb.Title
6 }
7 [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(${function:GetSiteElevatedPrivileges})

Tuesday, December 2, 2014

Enabling CORS

I was reading up on Enabling Cross-Origin Requests in ASP.NET Web API 2 It really cool what the Web API is evolving in to. I wanted to test the EnableCors attribute on my controller and in my rash I did read the hole article. I just pasted [EnableCors(origins: "", headers: "*", methods: "*")] in to my code and redeploy my solution. But no good, I was getting an error. I spend over 5 min doing trial n error. I even try to change the web.config in hand, to se if my client code was broken. When back to the article, a bit mad and discovered I was missing this single line of code config.EnableCors(); in the WebApiConfig class.

So mental note, cross-origin-requests is now really nice to manage with EnableCors and always read the highlighted part of a technical article!