Pages

Sunday 25 November 2012

How to manage multiple remote desktop sessions

If you are sysadmin or anyone who needs to manage multiple remote desktop sessions, then this free tool is a must. It's called Remote Desktop Connection Manager, free from Micorsoft.

http://www.microsoft.com/en-us/download/details.aspx?id=21101

Tuesday 20 November 2012

How to log the output to a text file for a powershell script

Problem

Some times when performing bulk operations you would want to log the output of a powershell script to a text file, so you can examine the results and perhaps even investigate what went wrong.

Solution:

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue"
Start-Transcript -path C:\Admin\SiteFeaturesoutput.txt -append


.
.
Your script goes here
.
.
Stop-Transcript

Sunday 11 November 2012

How to get crawled properties for a document using Powershell in SharePoint 2010


(This is an exact copy from this site: I have created this post for my Personal Reference)


In order to get the crawled properties for a document copy the powershell command, this information can be used to create Managed Properties for search.



Function Get-CrawledPropertyNames([string]$DocURL){  
$DocURL = $DocURL.Replace("%20"," "$webfound = $false 
$weburl = $DocURL 
 
while ($webfound -eq $false) { 
    if ($weburl.Contains("/")){ 
    $weburl = $weburl.Substring(0,$weburl.LastIndexOf("/")) 
    $web = get-spweb -identity $weburl -ea 0 
    if ($web -ne $null){ 
        $webfound = $true 
    } 
    }else{ 
    Write-Host -ForegroundColor Red "The Web could not be found" 
    return -1 
    } 
     
} 
$web.GetFile($DocURL).item.xml.Replace("' ""' `n").Replace("`" ", "`" `n") 
} 


#To use enter the url of a file within a doucment library 
Get-CrawledPropertyNames "http://sites/doc/file.pdf" 
 
The output: 




Thursday 1 November 2012

How to ensure the field value is the same in a repeating section in an InfoPath form hosted in SharePoint 2010 Forms library

Scenario:
Consider this: You have a information request form at a school. When someone (who is an authorised requester) requests information for a student. The admin staff use this form to record the information sent to the requester for legal reasons. The admin staff are allowed to add multiple students for the same request however, the students need to be from the same school.

When the admin staff login, their details are populated automatically from GetUserProfileByName web service.


`Figure 1

The form has a repeating control as seen in Figure 2 (People Picker Control + Label (Field Name is ChildSchool)) in an InfoPath form which is published to a Form Library in SharePoint 2010


Figure 2
Problem:
Since it is a repeating section, you cannot control or know the number of instances of the control. A user can add many by clicking the insert link.

Solution:
Add another control (text) to form called AllSchoolNames, it does not have to be visible on the form it is just used to calculate the total number of schools
Figure 3

Click properties of the AllSchoolNames field and add this to the Value field under Default Value Section
eval(eval(NameOfChilds, 'concat(../my:childSchool, substring(";", 1, string-length(../my:childSchool)))'), "..")




Click on "fx" and click on "Edit XPath (advanced)" - Ensure your values look similar to this:

xdMath:Eval(xdMath:Eval(../my:NameOfChild/my:NameOfChilds, 'concat(../my:childSchool, substring(";", 1, string-length(../my:childSchool)))'), "..")

This will return either o (false) or 1 (true)

That's it. Based on the return value you can include Rules to perform an action.

Hope it helps:
References:

http://www.infopathdev.com/forums/p/7124/75545.aspx