tag:blogger.com,1999:blog-36327073289311367332024-03-13T21:23:30.823-07:00SharePoint TipsThis blog contains some SharePoint tips that I want to share.Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-3632707328931136733.post-66905042843629037212011-12-16T13:32:00.000-08:002011-12-16T13:33:23.477-08:00The query cannot be run for the following DataObject: GetCommonManagerI got that message when I previewed an InfoPath form (SharePoint Server 2010, InfoPath 2010):<br />
<br />
<b>The query cannot be run for the following DataObject: GetCommonManager </b><br />
<b>InfoPath cannot run the specified query. </b><br />
<b>The SOAP response indicates that an error occurred on the server: </b><br />
<b>Server was unable to process request. ---> Object reference not set to an instance of an object.</b><br />
<br />
I knew that new User Profile Service Application had been created and it used to work with old one without issues. The UserProfileService web service was healthy and calls for GetUserProfileByName were proceeded well. It just stuck with GetCommonManager call.<br />
<br />
After some investigation I found My Site host was not defined in that brand new User Profile Service Application. When I defined it My Site Settings for the application
GetCommonManager started working again.<br />
<br />
Hope that helps save time someone.<br />
<br />
<br />Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com0tag:blogger.com,1999:blog-3632707328931136733.post-10169799206452556592011-04-20T08:45:00.000-07:002011-04-20T09:07:52.577-07:00Title column value in ItemUpdating event for Document LibraryI had to add some logic in ItemUpdating event receiver when anything was changed except one particular column. This had to work for both lists and libraries.<br />There some good posts about differences in properties for lists and libraries, e.g. <a href='http://www.synergyonline.com/blog/blog-moss/Lists/Posts/Post.aspx?ID=25' target='_blank'>this one from Randy Williams</a>.<br /><br />My code was <br /><code class="myCodeSnipped"><br /> string[] ignoreFields = new string[] { "myField" };<br /> foreach (SPField field in properties.ListItem.Fields)<br /> {<br /> if (!ignoreFields.Contains<string>(field.InternalName) &&<br /> properties.AfterProperties[field.InternalName] != null &&<br /> (properties.ListItem[field.Id] == null ||<br /> properties.ListItem[field.Id].ToString() != properties.AfterProperties[field.InternalName].ToString()))<br /> {<br /> // do something<br /> }<br /> } <br /></code><br /><br />This worked well for lists but I struggled with Title column in libraries.<br />I found <b>properties.AfterProperties["Title"] is always null for libraries even when Title was changed</b>.<br /><br />After intensive googling I found that for libraries properties.ListItem.Title is mapped to properties.AfterProperties["vti_title"].<br /><br />So, I had to add this<br /><code class="myCodeSnipped"><br /> if (properties.List is SPDocumentLibrary && properties.ListItem.Title != properties.AfterProperties["vti_title"])<br /> {<br /> // do something<br /> }<br /></code>Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com1tag:blogger.com,1999:blog-3632707328931136733.post-1123350868639829252011-03-10T08:51:00.000-08:002011-12-09T13:08:06.879-08:00No paging on SharePoint groups pageI don't know exact reason but this was a fact: I have more than 30 SharePoint groups in particular site collection and no paging at all. For other site collections paging is there.<br /><br />I was very annoying: I had to filter by group name to have access to members list for groups with name started with 'k' and below.<br /><br />I googled and found this is actually a hidden view of User Information List. Looked like it had 'Limit the total number of items returned to the specified amount' set under 'Items limit' instead of 'Display items in batches of the specified size'. So, the question was <b>How to get access to its View Edit page?</b><br /><br />Actual View Edit page is an application page in layouts folder (_layouts/viewedit.aspx) and it accepts two parameters in query string: List and View ids.<br /><br />What I did:<br /><br />- went to the groups page (http://spSite/_layouts/groups.aspx)<br /><br />- opened page source and found list and view guids there. The answer was searching by WebQuerySourceHref= phrase. I found url with this values there.<br /><br />- went to http://spSite/_layouts/viewedit.aspx?List={630F7EE7-1EA5-45F5-A162-4523647E1564}&View={132D30FA-EAD7-4134-B328-DB873CE82BD0}<br />(ids are mine :)<br /><br />- changed the settings under 'Items limit'Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com3tag:blogger.com,1999:blog-3632707328931136733.post-30565968288140812792011-03-03T13:10:00.000-08:002011-03-03T13:20:59.603-08:00Accessing mixed authentication web app with Client Object Model and Web SericesI have mixed authentication web app in SharePoint 2010: both Windows (NTLM) and Forms based.<br />When I tried to access it using Client Object Model with my NTLM credentials I got 401 (Unauthorized) exception. I googled and found this solution<br /><code class="myCodeSnipped"><br />...<br />clientContext.ExecutingWebRequest += new EventHandler(clientContext_ExecutingWebRequest);<br />...<br />}<br /><br />static void clientContext_ExecutingWebRequest(object sender, WebRequestEventArgs e)<br />{<br />e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");<br />}<br /></code><br /><br />This works well for me.<br /><br />Then when I tried to access same site using Lists.asmx web service with same NTLM credentials I got exactly same exception.<br />I added this method to the Web Service wrapper class (it's in Web References > ListWebService > Reference.map > Reference.cs in my case)<br /><br /><code class="myCodeSnipped"><br />protected override System.Net.WebRequest GetWebRequest(Uri uri)<br />{<br />System.Net.WebRequest wr = base.GetWebRequest(uri);<br />wr.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");<br />return wr;<br />}<br /></code><br />That solved the issue as well.Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com7tag:blogger.com,1999:blog-3632707328931136733.post-84281736335572857552011-03-01T07:35:00.000-08:002011-03-01T08:25:37.776-08:00How to attach files to list item using Client Object ModelNo way. It is just impossible to do that using Client Object Model.<br /><br />This is my story.<br /><br />The task was to copy list item with attachments to another location of separate farm. Everything was going fine. There are tons links in Google how to work with SharePoint 2010 Client Object Model. So my code was like that:<br /><br /><code class="myCodeSnipped"><br />foreach (string attachment in sourceItem.Attachments)<br />{<br />string fileUrl = SPUtility.ConcatUrls(sourceItem.Attachments.UrlPrefix, attachment);<br />SPFile file = sourceItem.Web.GetFile(fileUrl);<br />Stream fs = file.OpenBinaryStream(SPOpenBinaryOptions.SkipVirusScan);<br /><br />string attachmentPath = string.Format("{0}/{1}/Attachments/{2}/{3}", SPUtility.ConcatUrls(targetContext.Web.ServerRelativeUrl,"Lists"), targetListName,<br />targetItem.Id, attachment);<br /><br />Microsoft.SharePoint.Client.File.SaveBinaryDirect(targetContext, attachmentPath, fs, true);<br />}<br /></code><br /><br />Looks good, doesn't it? However when I ran it ... ups ... I got <b>409(Conflict)</b> error message. After debugging and checking attachmentPath was correct (e.g. <i>/Lists/testList/Attachments/10/testFile.doc</i>) I googled the error and found the most possible reason was the folder not found on the target. Actually it wasn't. Folder for item id (<i>10</i>) in attachmentPath is never exist in this stage by design because targetItem had been just created. But SaveBinaryDirect doesn't create folder. It just save file and expects correct path provided.<br />I tried to create the folder with ListItemCreationInformation object but without any success. That technique is for creating ordinary folders and doesn't work for creating folders under Attachments folder. Then I found this <a href="http://stackoverflow.com/questions/2969810/sharepoint-2010-client-object-model-add-attachment-to-listitem">stack overflow thread</a>. Looks like <b>Microsoft had confirmed it is not possible to achieve that using Client Object Model</b>.<br /><br />The only one way for now is using Lists.asmx web service.<br />So, I added web reference to the web service. In VS 2010 I did right click on References, then 'Add Server Reference', then clicked 'Advanced...' button on the bottom and provider web service url (any existing url e.g. http://spdev/_vti_bin/lists.asmx in my case).<br /><br />This is my final code<br /><code class="myCodeSnipped"><br />ListsWebService.Lists objLists = new ListsWebService.Lists();<br />objLists.Credentials = targetContext.Credentials;<br />objLists.Url = SPUtility.ConcatUrls(targetWebUrl, "/_vti_bin/lists.asmx");<br /><br />foreach (string attachment in sourceItem.Attachments)<br />{<br />string fileUrl = SPUtility.ConcatUrls(sourceItem.Attachments.UrlPrefix, attachment);<br />SPFile file = sourceItem.Web.GetFile(fileUrl);<br />byte[] fileContent = file.OpenBinary(SPOpenBinaryOptions.SkipVirusScan);<br />objLists.AddAttachment(targetListName, targetItem.Id.ToString(), file.Name, fileContent);<br />}<br /></code><br /><br />Hope it helps someone make things clear.Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com3tag:blogger.com,1999:blog-3632707328931136733.post-49538514180864047362011-02-18T05:46:00.000-08:002012-05-30T07:39:57.411-07:00Setting time out for Silverlight web partThere is the way to set time out for Silverlight web part. This time out happens when web part can't load xap file.<br />
The value is hard-coded within web part and equal 5 sec which is not so much.<br />
First of all where this value is hard-coded? If you viewed source of the page with Silverlight web part you could found javascript line like that<br />
<code class="myCodeSnipped"><br />window.setTimeout("_spCheckIfSilverlightPluginIsLoaded_WebPart<span style="font-weight: bold;">ctl00_m_g_0f7cd87d_f3fd_49d9_91ec_ad4b46cfe999</span>();", 5000);</code><br />
This is our bad guy. Value 5000 is hard-coded and function name contains web part Id (<span style="font-weight: bold;">ctl00_m_g_0f7cd87d_f3fd_49d9_91ec_ad4b46cfe999</span> in my case).<br />
<br />
So, the easiest way to handle it is to eliminate time out at all by creating same named dummy JavaScript function:<br />
<br />
1. Go to page source and search for <b>_spCheckIfSilverlightPluginIsLoaded_WebPart</b> phrase. You suppose to find function which starts with this phrase. Copy function name to clipboard.<br />
<br />
2. Add content editor web part <b>after</b> Silverlight web part and put empty JavaScript function with saved name there like that<br />
<code class="myCodeSnipped"><br /><script type="text/javascript"><br />function _spCheckIfSilverlightPluginIsLoaded_WebPartctl00_m_g_0f7cd87d_f3fd_49d9_91ec_ad4b46cfe999(){}<br /></script></code><br />
<br />
where <span style="font-weight: bold;">_spCheckIfSilverlightPluginIsLoaded_WebPartctl00_m_g_0f7cd87d_f3fd_49d9_91ec_ad4b46cfe999</span> is a function name I've found on my page. <br />
<br />
<b><span style="color: red;">> Update!</span></b> - one more (even better!) workaround:<br />
<br />
You can override _spSetSLPluginNotLoadedErrorMessage function which is called by web part if XAP file wasn't loaded in 5 sec.<br />
<br />
1. Just drop this tag in Content Editor web part on the page:<br />
<code class="myCodeSnipped"><br /></code><br />
<code class="myCodeSnipped">
<script type="text/javascript">
function _spSetSLPluginNotLoadedErrorMessage(wpId){ </code><br />
<code class="myCodeSnipped">} </code><br />
<code class="myCodeSnipped"></script>
</code>
<br />
<br />
> end of update<br />
<br />
This is working just fine if you have couple pages with Silverlight web part and you are Ok do not have any time out.<br />
<br />
Better but little bit more complicate way is creating javascript to set a new time out value. Main idea is put some code in our dummy function with new time out value. I created a web part for that. It is <a href="http://sltimeout.codeplex.com/">on codeplex</a>.<br />
It scans the page for Silverlight web parts and renders javascript for each instance. It has just one property - time out :)<br />
<br />
Please note this web part should be on your page <b>after</b> Silverlight web part.<br />
<br />
How I tested it:<br />
I put two Silverlight web parts to my page with wrong reference to xap file. I got time out in 5 secs on both. Then I put my web part in between. I got time out in 15 secs (my default value) for the first Silverlight web part and still 5 secs for the second.<br />
<br />
You can check out <a href="http://sltimeout.codeplex.com/releases/61213/download/209117">wsp package</a> and <a href="http://sltimeout.codeplex.com/releases/61213/download/209130">source code</a>.<br />
<br />
Have fun with Silverlight!Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com3tag:blogger.com,1999:blog-3632707328931136733.post-61805313454156197852011-01-07T06:08:00.000-08:002011-01-19T08:01:11.499-08:00WSS-like breadcrumb in SharePoint 2010This was the first user's request after migration had been done. It wasn't very important. Just annoying. I played some time with site navigation and ended up with jQuery. There is a kind of WSS-like breadcrumb on SharePoint 2010 master page but now it is a pop-up. The idea is to put it to page in usual way.<br /><br />1. Add reference to jQuery into your master page, e.g.<br /><code class="myCodeSnipped"><br /><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><br /></code><br /><br />just before tag </head><br /><br />2. Add breadcrumb holder div and jQuery next to it where you want to see it<br /><code class="myCodeSnipped"><br /><div class="wss-BreadCrumb"></div><br /> <script type="text/javascript"><br /> $("a.s4-breadcrumbRootNode").clone().appendTo('div.wss-BreadCrumb');<br /> $("a.s4-breadcrumbNode").clone().appendTo('div.wss-BreadCrumb');<br /> $("a.s4-breadcrumbCurrentNode").clone().appendTo('div.wss-BreadCrumb');<br /> $("<span>></span>").insertAfter('div.wss-BreadCrumb a.s4-breadcrumbRootNode');<br /> $("<span>></span>").insertAfter('div.wss-BreadCrumb a.s4-breadcrumbNode');<br /> $("span.s4-breadcrumbCurrentNode").clone().appendTo('div.wss-BreadCrumb');<br /> </script><br /></code><br /><br />3. Add styles to make it looks like WSS breadcrumb<br /><code class="myCodeSnipped"><br />div.wss-BreadCrumb<br />{<br /> margin-bottom:5px;<br /> display: inline-block;<br />}<br /><br />div.wss-BreadCrumb span<br />{<br /> margin-left:5px;<br /> margin-right: 5px;<br />}<br /><br />div.wss-BreadCrumb span.s4-breadcrumbCurrentNode<br />{<br /> margin-left:0px;<br /> margin-right:0px;<br />}<br /><br /><br />div.wss-BreadCrumb a.s4-breadcrumbNode, div.wss-BreadCrumb a.s4-breadcrumbCurrentNode,<br />div.wss-BreadCrumb a.s4-breadcrumbRootNode<br />{<br /> color: blue;<br />}<br /><br /></code>Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com0tag:blogger.com,1999:blog-3632707328931136733.post-30615827450190682482010-10-21T13:27:00.000-07:002011-01-18T06:59:15.905-08:00DisableEventFiring is obsolete in SharePoint 2010You can check this in <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverbase.disableeventfiring.aspx">msdn</a>. However <span style="color: rgb(255, 0, 0);font-family:arial;font-size:100%;" >DisableEventFiring()/EnableEventFiring()</span> still works as per Reflector.<br />Recommended way now is to use new property <span style="color: rgb(255, 0, 0);">EventFiringEnabled</span>. This gives us an option to check current status and save it. I found <a href="http://adrianhenke.wordpress.com/2010/01/29/disable-item-events-firing-during-item-update/">a great post from Adrian Henke</a> and modified his code using this new feature.<br /><br /><script src="https://gist.github.com/672663.js?file=DisabledItemEventsScope.cs"></script><br /><br />The class <span style="color: rgb(255, 0, 0);">DisabledItemEventsScope</span> disable/enable event firing for the current thread and could be used in that manner at any place <b>including code behind for the page or web part</b><br /><br /><script src="https://gist.github.com/672705.js"> </script><br /><br />BTW: There are couple useful SPList extensions to manage SPListItemEventReceiver collection<br /><br /><script src="https://gist.github.com/672687.js?file=SPListExtensions.cs"></script>Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com1tag:blogger.com,1999:blog-3632707328931136733.post-84629026285633441512010-10-11T19:32:00.000-07:002010-10-12T06:59:09.379-07:00SPUrl for WSS 3.0 or SharePoint FoundationNo, expression like <% $SPUrl:~sitecollection/Style Library/mystyles.css %> doesn't work for WSS or SharePoint Foundation. This is part of Publishing Infrastructure and you have to buy MOSS or SharePoint Server license to get it.<br /><br />So, let's create our own ExpressionBuilder. I didn't implement 'language' support - obviously I need just Site and SiteCollection.<br /><br /><code class="myCodeSnippet"><br />...<br />using System.Web.Compilation;<br />using Microsoft.SharePoint;<br /><br />...<br />public class WSSUrlExpressionBuilder : ExpressionBuilder<br />{<br />public override CodeExpression GetCodeExpression<br /> (System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)<br />{<br />CodeTypeReferenceExpression thisType = new CodeTypeReferenceExpression(base.GetType());<br /><br />CodePrimitiveExpression expression = new CodePrimitiveExpression(entry.Expression.Trim().ToString());<br /><br />string evaluationMethod = "GetKeyValue";<br /><br />return new CodeMethodInvokeExpression(thisType, evaluationMethod, new CodeExpression[] { expression });<br />}<br /><br />public static object GetKeyValue(string expression)<br />{<br />SPWeb web = SPContext.Current.Web;<br /><br />string key = "~SiteCollection";<br />if (expression.IndexOf(key, StringComparison.InvariantCultureIgnoreCase) == 0)<br /> return web.Site.Url+expression.Substring(key.Length);<br /><br />key = "~Site";<br />if (expression.IndexOf(key, StringComparison.InvariantCultureIgnoreCase) == 0)<br /> return web.Url+ expression.Substring(key.Length);<br /><br />return expression;<br />}<br /><br />}<br />...<br /></code><br /><br />You need to put this class to some assembly and register it with your prefix(e.g. WSSUrl) in Web.Config<br /><br /><code class="myCodeSnippet"><br /><configuration><br /><system.web><br /> <compilation><br /> <expressionBuilders><br /> <add expressionPrefix="WSSUrl"<br /> type="{your Namespace}.WSSUrlExpressionBuilder,{Assembly Name}"/><br /> </expressionBuilders><br /> </compilation><br /></system.web><br /></configuration><br /></code><br /><br />Assembly Name should be fully qualified if you put the assembly into GAC.Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com2tag:blogger.com,1999:blog-3632707328931136733.post-91033153943811684732010-10-07T07:25:00.000-07:002010-10-07T07:47:58.677-07:00SharePoint: How to get document icon imageThere is a method in SPUtility which makes it much easier. It takes image file name from docicon.xml, and should work Ok even if the file name is not follow the pattern ic{doc ext}.gif<br /><br /><code class="myCodeSnippet"><br />string docIcon = SPUtility.ConcatUrls("/_layouts/images/",<br /> SPUtility.MapToIcon(item.Web,<br /> SPUtility.ConcatUrls(item.Web.Url,item.Url), "", IconSize.Size16));<br /></code><br /><br />There is a good post about <a href="http://www.bwaretech.com/en/Community/Team_Blog/EntryId/12/SPUtility-MapToIcon-vs-SPFile-IconUrl.aspx">SPUtility.MapToIcon vs SPFile.GetIcon</a>Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com0tag:blogger.com,1999:blog-3632707328931136733.post-30114172531595684542010-09-10T06:52:00.000-07:002010-10-12T17:37:55.461-07:00SharePoint 2010: How to add back QuickLaunch to the web part page.Actually this is not adding but just removing hiding functionality:<br /><br />1. Remove this code/css from the page<br /><code class="myCodeSnippet"><br /><SharePoint:UIVersionedContent ID="WebPartPageHideQLStyles" UIVersion="4" runat="server"><br /><ContentTemplate><br /><style type="text/css"><br />body #s4-leftpanel {<br />display:none;<br />}<br />.s4-ca {<br />margin-left:0px;<br />}<br /></style><br /></ContentTemplate><br /></SharePoint:UIVersionedContent><br /></code><br /><br />2. Remove this place holder <strong>from the page</strong><br /><code class="myCodeSnippet"><br /><asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content><br /></code>Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com5tag:blogger.com,1999:blog-3632707328931136733.post-30829567453860947832010-09-02T09:08:00.000-07:002016-06-14T07:52:51.469-07:00Restart SPTimerV4 service remotely in the SharePoint farmThere is a PowerShell script which restarts SPTimerV4 service remotely on every application server within a farm. This is useful when deployment of a SPTimerJob has been done.<br />
<br />
It should be run on one of the application servers under SharePoint 2010 Management Shell, and you have to have enough permissions of course.<br />
<code class="myCodeSnipped"><br /></code>
<span style="font-family: monospace;">foreach ($server in (get-spserver | Where {$_.Role -eq "Application"}) )</span><br />
<span style="font-family: monospace;">{</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>write-host $server.Name</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$service = Get-Service -computer $server.Name -name SPTimerV4</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if ($service.Status -ne "Stopped")</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$service.Stop()</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Do</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>start-sleep -s 5 | out-null</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>write-host '.' -noNewLine</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$service = Get-Service -computer $server.Name -name SPTimerV4</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>While ($service.Status -ne "Stopped")</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>write-host $service.Status</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>else</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>write-host "Stopped already"</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if ($service.Status -ne "Running")</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$service.Start()</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Do</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>start-sleep -s 5 | out-null</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>write-host '.' -noNewLine</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$service = Get-Service -computer $server.Name -name SPTimerV4</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>While ($service.Status -ne "Running")</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>write-host $service.Status</span><br />
<span style="font-family: monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: monospace;">}</span><br />
<br />
It shows the state of the service for each server. So, you can go and restart it manually if something was going wrong.Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com0tag:blogger.com,1999:blog-3632707328931136733.post-90187919175733744782010-08-31T05:54:00.001-07:002010-10-12T17:39:40.140-07:00Hide SharePoint 2010 Ribbon Control from public users<span style="font-family:arial;">There are some posts about how to hide SharePoint 2010 Ribbon from users with least permissions. One example is </span><a href="http://www.topsharepoint.com/hide-the-ribbon-from-anonymous-users"><span style="font-family:arial;">here</span></a><span style="font-family:arial;">. But it <strong>trims</strong> the ribbon from the page, which could cause some issues. Most known is a scroll bar disappearing.<br />BTW: there is <a href="http://blogs.msdn.com/b/sharepoint/archive/2010/04/06/customizing-ribbon-positioning-in-sharepoint-2010-master-pages.aspx">a perfect article</a> about SharePoint 2010 Ribbon Control from its designer. </span><br /><span style="font-family:Arial;"></span><br /><span style="font-family:arial;">There is the way how to real <strong>hide</strong> it depending of current user permissions (owner permission in this example). Just add this to the head section on master page.</span><br /><span style="font-family:arial;"></span><code class="myCodeSnippet"><br /><style type="text/css"><br />div#s4-ribbonrow {<br />display:none;<br />}<br /></style><br /><br /><Sharepoint:SPSecurityTrimmedControl runat="server"<br />Permissions="AddAndCustomizePages"><br /><style type="text/css"><br />div#s4-ribbonrow {<br />display:block;<br />}<br /></style><br /></Sharepoint:SPSecurityTrimmedControl><br /></code>Vladimir Buyevichhttp://www.blogger.com/profile/12087586274978917518noreply@blogger.com1