Export-SPWeb script to get backup all lists and libraries

Wrote this Powershell script according to my company’s needs,but you can fork and use it if you like Export-SPWeb Script to get backup of all lists/libraries in a site collection. But I’ll also share it here: [code language=”powershell”] Add-PSSnapin Microsoft.Sharepoint.Powershell $site = Get-SPSite $path = "C:\Backup2015\ListBackups" $serverurlpath ="" $listurlpath="" $listurlwithoutformat="" $dosyapath ="" $itemURLNEW="" foreach($web in $site.AllWebs){ $serverurlpath=$web.Url $serverlistsurlpath=$web.ServerRelativeUrl -replace "/","\" $serverurlport = ([System.Uri]$serverurlpath).Port $serverurlhost = ([System.Uri]$serverurlpath).Host.Split(‘.-‘) -join "_" if($serverurlport -eq "80") { if(!(Test-Path -Path ($path + "\" + $serverurlport))) { New-Item -Path ($path + "\" + $serverurlport) -Type Directory }…

Read More

Solution of “Application Server Role, Web Server (IIS) Role: configuration error”

For some reason SharePoint 2013’s prerequisite msi cant find which server manager to use and fails installation of Prerequisite files. So you need to go Windows/System32, find servermanager.exe ,duplicate it and then rename it to servermanagercmd.exe After this,re-run prerequisite installer,it will work. If it doesn’t,you haven’t enabled downloading setup files remotely in mmc(group policy editor) settings. To do this; 1-You need to add “GP Editor” Snapin in MMC. 2-Go to Computer Configuration->Administrative Templates-> System 2-Update “Specify settings for optional…” policy as Enabled 3-Update “Contact Windows Update…” as selected 4-Click Apply

Read More

SharePoint 2013 REST API and Charset Problem

I’ve been on a project lately.The project was to migrate contents from a farm to another.Since there was corporate rules like a bank we couldnt use Content Migration tool in CA so our only option was to use SharePoint REST API. Whenever i sent values from a list in farm to another list in another farm,i had problems with non-english chars. For example; characters like “İ”,”Ç”,”Ğ” arent ASCII supported so my only option was to use “Encoding” There are a couple known drawbacks while using Encoding with HttpWebRequest so i implemented those…

Read More

Problem and Solution : Dynamic operations can only be performed in homogenous AppDomain.

If u have ever used “dynamic” keyword in your webpart code,its 100% possibility you will meet this error. Its because using dynamic operation in same appdomain as sharepoint is not supported in new LegacyCASModel. So heres a workaround i did to make it work: if you wrote a timerjob, edit owstimer.config otherwise edit web.config: Instead of this: <trust level=”Full” originUrl=”” legacyCasModel=”true” /> Use this: <trust level=”Full”  /> and add this to <configuration><runtime>: <NetFx40_LegacySecurityPolicy enabled=”false”/> Hope it helps

Read More

Get Yahoo Weather and Parse it in C#

Here’s a code i wrote for a sharepoint 2013 visual webpart which retrieves Istanbul’s temperature and condition text from Yahoo Weather (YQL) in JSON format and parsing. string results = “”; using (WebClient wc = new WebClient()) { results = wc.DownloadString(“https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%3D2344116&format=json”); } dynamic jo = JObject.Parse(results); var items = jo.query.results.channel.item.condition; var code = items.code; var temp = items.temp; var text = items.text; Console.WriteLine(code + ” – ” + temp + ” – ” + text); Console.Read();

Read More

Limit NewsFeed to Display Latest 5 Posts in SharePoint 2013

I was having an issue to retrieve latest posts from newsfeed,lets say take 5 of them.Tried everything,but newsfeed webpart didnt support filtering according to my need. So i tried a “css-trick” code i found over the internet and improved it to my needs: function get5posts() { $(“.ms-microfeed-seeMoreThreadsDivContainer”).hide(); var limit = 5; $(“#ms-feedthreadsdiv .ms-microfeed-thread”).each(function (i) { if (i >= limit) { $(this).addClass(“ms-hide”); } }); } The code above shows only 5 posts on page load.But what happens if you add more in newsfeed? The 5 item limit exceeds and you need…

Read More

Considerations after Backup & Restore in SharePoint

These are what i experienced on some of the projects i have worked on: 1) Scripts,Styles,Fonts,Layouts needs to be published.Because they stay as draft items in your “_catalogs/masterpage” 2) The lists that use filtering needs to be updated.Sometimes it bugs out. 3) If you have used NewsFeed in your portal,its contents need to be deleted from MicroFeed special list.Just click on the guid item and it will show the users posts.This is important because people will see users’ posts from the test environment 4) Never ever use SPContext.Current.Web.List(“blabla”) to access…

Read More

Get Attachments using SPServices in SharePoint 2013

[sourcecode language=”javascript”] $().SPServices({ operation: "GetListItems", async: false, listName: "listname", completefunc: function (xData, Status) { $(xData.responseXML).SPFilterNode("z:row").each(function() { $().SPServices({ operation:’GetAttachmentCollection’, listName: "listname", ID: $(this).attr("ows_ID"), completefunc: function (xData, Status) { $(xData.responseXML).find("Attachments").each(function() { alert($(this).text()); }); } }); }); } });[/sourcecode] But theres a much more better way to do it,Thanks to Marc: [sourcecode language=”javascript”] var p = $().SPServices({ operation: "GetListItems", listName: "listname", CAMLQueryOptions: "<QueryOptions>" + "<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls>" + "</QueryOptions>" }); p.done(function() { $(p.responseXML).).SPFilterNode("z:row").each(function() { var attachments = []; var att = $(this).attr("ows_Attachments"); if(att !== "0") { attachments = att.split(";#"); // Now you’ll have an array…

Read More