Enable Versions on every SharePoint Site with PowerShell (updated with logging)

The Script below will list the version status of every site in your farm.
Note that as the script is below, it only reports, you’ll need to uncomment 3 lines if you want it to make the changes.

It’s a good idea to run the script once or twice before you do that, so you have a log of what settings were.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
 
$timestamp = get-date -format "yyyMMdd_hhmmtt"
$filenameprefix = "VersionScriptoutput"
$logfile = ("{0}_{1}.csv" -f $filenameprefix, $timestamp)
 
$header = "ListURL,Enabled"
$header | out-file -filepath $logfile
 
# tip - the script as is will pull every sharepoint site (at the IIS level) in your farm.
# if you want to filter this to a single IIS site,
# remove the # from the middle of the next line and enter your site's url
 
$iissitelist = get-spwebapplication # | where {$_.url -eq "https://www.yoursite.com/"}
foreach ($iissite in $iissitelist)
{
	foreach ($SiteCollection in $iissite.sites)
	{
		write-host $SiteCollection -foregroundcolor Blue
		foreach ($oneweb in $SiteCollection.allwebs)
		{
		   write-host  $iissite.url $oneweb -foregroundcolor Green
		   #now this is is where we look at the lists
		   $lists = $oneweb.lists
		   foreach ($list in $lists)
		   {
			  if($list.EnableVersioning -eq $false)
			  {
				  write-host  $iissite.url $oneweb"/"$list"/ is a not using versions" -foregroundcolor yellow
				  $msg = ("{0}/{1},false" -f  $oneweb.url, $list.rootfolder)	
			           $msg | out-file -filepath $logfile -append
                                       # note!
                                       # if you actually want to make the changes, uncomment the next 3 lines!
				  #$list.Enableversioning = $true
				  #$List.MajorVersionLimit = 3
				  #$list.update()
			  }
			  else
			  {
				  Write-host  $iissite.url $oneweb"/"$list"/ has versions enabled! "
				  $msg = ("{0}/{1},true" -f  $oneweb.url,$list.rootfolder)				  
                                       $msg | out-file -filepath $logfile -append
			  }
		   } 
		}
	}
}

Powershell to enable Versioning for every list and library in a given sharepoint site

Update – A newer version of this script exists here- I’ve left this one here for search results, and because it’s scoped at the web level, whereas the new one is scoped at the IIS level.

This script will enable Versioning for every list and document library in a given sharepoint site.

I’d originally written it to just do document libraries, but changed my mind – things like announcements and calendars are lists, and they are equally important to protect. Same with some of the default libraries like “Site Assets”

Note that if the script sees that versioning is already enabled, it tells you – so no harm running the script more than once.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
$web = get-spweb "http://www.yoursharepointurl.com/sites/yoursite/"
$lists = $web.lists
foreach ($list in $lists)
{
    if($list.EnableVersioning -eq $false)
    {
         write-host $list.title "is a not using versions"
         $list.Enableversioning = $true
         $List.MajorVersionLimit = 5
         $list.update()
    }
    else
    {
         Write-host $list.title " is set for up to " $list.MajorVersionLimit "previous versions"
    }
}

Powershell Script to disable Certificate Revocation List (CRL)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#the following statement goes on one line
set-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing" -name State -value 146944
 
#the following statement goes on one line also
set-ItemProperty -path "REGISTRY::\HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing" -name State -value 146944
 
get-ChildItem REGISTRY::HKEY_USERS | foreach-object {set-ItemProperty -ErrorAction silentlycontinue -path ($_.Name + "\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing")  -name State -value 146944}
 
Write-Host -ForegroundColor White " - Disabling Certificate Revocation List (CRL) check..."
ForEach($bitsize in ("","64")) 
{			
  $xml = [xml](Get-Content $env:windir\Microsoft.NET\Framework$bitsize\v2.0.50727\CONFIG\Machine.config)
  If (!$xml.DocumentElement.SelectSingleNode("runtime")) { 
    $runtime = $xml.CreateElement("runtime")
    $xml.DocumentElement.AppendChild($runtime) | Out-Null
  }
  If (!$xml.DocumentElement.SelectSingleNode("runtime/generatePublisherEvidence")) {
    $gpe = $xml.CreateElement("generatePublisherEvidence")
    $xml.DocumentElement.SelectSingleNode("runtime").AppendChild($gpe)  | Out-Null
  }
  $xml.DocumentElement.SelectSingleNode("runtime/generatePublisherEvidence").SetAttribute("enabled","false")  | Out-Null
  $xml.Save("$env:windir\Microsoft.NET\Framework$bitsize\v2.0.50727\CONFIG\Machine.config")
}

PowerShell to activate a SharePoint 2010 feature on every site collection in a web app

I recently was given a WSP to add to our farm.

In this case after the WSP was installed and deployed we needed to activate the feature at the site collection level.
Thats usually easy enough to do through the UI, but in this particular case we had a web application which had over a dozen site collections.

ie:

  • http://jack.com
  • http://jack.com/blog
  • http://jack.com/marketing
  • 10 more like the above…

Activating it at http://jack.com from the UI was fine, but when the user navigated to http://jack.com/blog they were stumbling onto another site collection, and the feature wasn’t activated there.

To activate it on every Site collection meant that I’d have to a) know what each site collection was, and b) visit that site, and activate the feature.

Too much work.

What was needed was a simple script that would loop though each site collection, enabling the feature on each one.

The script below is a result of that need…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
 # this script enables a feature on every site collection on a given web app
 
 Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
 $webs =  get-spsite -webapplication "http://www.yoursharepointURL.com"
 $feature = "YourFeatureName" #this might not be what you expect it to be, best to do get-spfeature | Select displayname
 
  Foreach ($oneweb in $webs)
  {
    write-host $oneweb
    $siteFeature = get-spfeature -site $oneweb | Where {$_.displayname -eq $feature}
    if ($siteFeature -eq $null)
    {
      Write-Host "Activating Site level Features at $oneweb" -foregroundcolor Yellow
      Enable-SPFeature -Identity $Feature -URL $oneweb.URL -Confirm:$False
    }
    else
    {
      Write-Host "Feature $feature is already activated on $oneweb" -foregroundcolor green
    }
  }

If you look at the simple logic, you’ll see you can run it more than once – and the second time you run it, it should display an all green list indicating that all the site collections already have the feature activated.

Powershell to test a URL against UAG rulesets

Many companies use Microsoft Forefront Universal Access Gateway (UAG) to publish sharepoint sites to the public internet.

We recently had a problem where office (word, excel, powerpoint) documents would not open through a sharepoint published site Via UAG in the office app on the end users home PC.

In UAG there’s a bunch of rules that match the URL in question via a regex.
We needed a quick way to test our URL against the regex in each and every rule so we knew which rules applied.

There currently isn’t a way to do that in UAG (there should be)
So as an alternate to doing these manually, I used the “Export rules” feature, then wrote the following powershell script to parse the exported file, gather the RegEx’s of each, and test the URL in question against each RegEx so you can see what rule is actually being applied.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# if you run from ISE and get a permissions error copy and paste everything to a new tab.
# or run get-executionpolicy (take note what it is) then run (as an administrator): set-executionpolicy unrestricted
#set theses two variables -
$ExportedRuleSetFile = get-content 'c:\PS\PRD_URLset.txt'
$URLtoFind = "/get/content/from/sharepoint.aspx"
Function FindAMatch($Rulefile, $URL)
{
	$table = New-Object system.Data.DataTable "RegExList"
	$col1 = New-Object system.Data.DataColumn Section,([string])
	$col2 = New-Object system.Data.DataColumn Name,([string])
	$col3 = New-Object system.Data.DataColumn RegEx,([string])
	$table.columns.add($col1)
	$table.columns.add($col2)
	$table.columns.add($col3)
 
	$row = $table.NewRow()
	$row.Section = "Section"
	$row.name = "Name"
	$row.RegEx = "Regex"
 
	foreach ($line in $Rulefile )
	{
		if ($line[0] -eq "[")
		{
			$table.Rows.add($row)
			$row = $table.NEwRow()
			$row.Section = $line
		}
		elseif ($line.substring(0,7) -eq "m_regex")
		{
			$row.RegEx = $line.substring(8)
		}
		elseif ($line.substring(0,7) -eq "m_name=")
		{
			$row.Name = $line.Substring(7)
		}
	}
	$table.Rows.add($row)
 
	write-host Note: this only searches SharePoint Rules
	# note the select statement is needed because many of the records don't have regex values
	foreach ($record in $table.select("name like 'SharePoint%'"))
	{
		if ($url -match $record.regex)
		{
			Write-host $url found in $record.name via regex matching $record.regex
		}
	}
} #end function
FindAMatch $ExportedRuleSetFile $URLtoFind

Sample output looks like this:

Note: this only searches SharePoint Rules
/get/content/from/sharepoint.aspx found in SharePoint14AAM_Rule1 via regex matching (/[^"#&*+:<>?\\{|}~]*)/?
/get/content/from/sharepoint.aspx found in SharePoint14AAM_Rule47 via regex matching (/[^"#&*+:<>?\\{|}~]*)*/[^"#&/:<>?\\{|}~]*\.aspx
/get/content/from/sharepoint.aspx found in SharePoint14AAM_Rule48 via regex matching /
/get/content/from/sharepoint.aspx found in SharePoint14AAM_Rule60 via regex matching (/[^"#&*+:<>?\\{|}~]*)/?

As a side note, we were able to pinpoint the rule that applied to our URL which made fixing it much easier!

Sharepoint 2010 ULS logs – How to keep them in SQL

This is another “Wow that was easy!” SharePoint items…

Open Central Admin
Go to the Monitoring section, then under “Timer Jobs”, select “Review job definitions”

There’s a timer job called “Diagnostic Data Provider: Trace Log”

It’s disabled by default, enable it and it will create new tables and a view on your logging database. (I think by default this is named WSS_Logging)
Leave it enabled (mine is set to run every 10 minutes)

Open SQL server Management studio and connect to your sharepoint DB server.
expand the WSS_Logging DB
Expand Views
Look for the new view called “ULSTraceLog”

I usually right click on the view name and “Select Top 1000 Rows”
Then from there I can add a where clause to the query thats on screen,
most often it’s
WHERE CorrelationID = ‘abcd-efg-hijk-lmnop-qrstuv’

Another tip- in the results (which on my system default to the “grid” view),
Right Click, Select All, then
Right Click, Copy with headers
you can then paste this into Excel and it’s pretty readable if you need to email it to someone.

As a side note, I’ve enabled this on a handful of farms and it seems to auto trim the DB sizes – so you don’t need to worry about the DB filling up over time.

Powershell script to add a list of users to the site collection administrators group of every site on your SharePoint 2010 farm.

I wanted a way to inject myself as a site collection admin into every site in sharepoint, Note, I’m not talking about the primary/secondary that you can set in Central admin.
I’m talking about that group you can only get to from within each site itself. Or in this case, with the powershell script below…
Note that it takes an array of names – if you have a team of admins or developers that all need access, you can put all their names in the list.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# set site collection owner for all sites...
# 1-2012
Add-PSSnapin Microsoft.SharePoint.PowerShell
 
# $AccountList is an array of Windows Identities in the format of $AccountList = @("DOMAIN\USERID" , "DOMAIN\USERID2")
$AccountList = @("LAB\Jack", "Lab\tom", "Lab\dick", "lab\harry")
 
#this gets an array of objects representing the sites at the IIS level:
$IISSites = Get-SPWebApplication
Foreach($oneIISSite in $IISSites)
{
   #using .Sites, we can get a list of the site collections
   foreach ($SharepointSiteCollection in $oneIISSite.Sites)
   {
      write-host $SharepointSiteCollection.url -ForegroundColor Cyan
      $spweb = Get-SPWeb $SharepointSiteCollection.url
 
      #now we have the website, so lets look at each account in our array
      foreach ($Account in $AccountList)
      {
         #lets see if the user already exists
         Write-host "Looking to see if User " $account " is a member on " $SharepointSiteCollection.url -foregroundcolor Blue
         $user = Get-SPUSER -identity $Account -web $SharepointSiteCollection.url -ErrorAction SilentlyContinue #This will throw an error if the user does not exist
         if ($user -eq $null)
         {
            #if the user did NOT exist, then we will add them here.
            $SPWeb.ALLUsers.ADD($Account, "", "", "Added by AdminScript")
            $user = Get-SPUSER -identity $Account -web $SharepointSiteCollection.url
            Write-host "Added user $Account to URL $SPWeb.URL" -Foregroundcolor Magenta
         }
         else
         {
            Write-host "user $Account was already in URL " $SPWeb.URL -Foregroundcolor DarkGreen
         }
         if ($user.IsSiteAdmin -ne $true)
         {
            $user.IsSiteAdmin = $true
            $user.Update()
            Write-host "$account has been made an admin on $SPWeb.URL" -Foregroundcolor Magenta
         }
         else
         { 
         Write-host "$account was already an admin on $SPWeb.URL" -Foregroundcolor DarkGreen
         }
     }
     $SharePointSiteCollection.Dispose()
}
}

 

Here’s another version of the script, this one also takes an array of top level URL’s

It’s handy if you have lots of url’s on your site and only want to work with a few of them.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# set site collection owner for all sites...
# 2-2013 Jack
 
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$logfile = "Powershelloutput.log"
 
# $AccountList is an array of Windows Identities in the format of $AccountList = @("DOMAIN\USERID" , "DOMAIN\USERID2")
$AccountList = @("domain\tom", "domain\dick", "domain\harry")
 
# $iisSiteList is an array of top level IIS site URLs
$iisSiteList = @("http://site1.yoururl.com", "http://anothersite.yoururl.com")
 
# this is from an earlier version of the script
# That scrip looks at all SP sites on the farm, I've left the old code here for reference
# this gets an array of objects representing the sites at the IIS level:
##  $IISSites = Get-SPWebApplication
 
Foreach($oneIISSite in $IISSiteList)
{
  #using .Sites, we can get a list of the site collections
  #so really what were saying is for each SharepointSiteCollection
 
  #this code is altered a bit, since we're using an array of top level site names.
  # we need to use (Get-SPWebApplication $oneIISSite).Sites
  # which is the same as $sitelist = Get-SPWebApplication $oneIISSite
  #                      $sitelist.sites
  foreach ($SharepointSiteCollection in (Get-SPWebApplication $oneIISSite).Sites)
  {
       $msg = $SharepointSiteCollection.url
       write-host  -ForegroundColor Cyan $msg
       Add-Content $logfile $msg
 
       $spweb = Get-SPWeb $SharepointSiteCollection.url
 
       #now we have the website, so lets look at each account in our array
       foreach ($Account in $AccountList)
       {
           #lets see if the user already exists  
           $msg = "Looking to see if User " + $account + " is a member on " + $SharepointSiteCollection.url
           Write-host -foregroundColor Blue $msg
           Add-Content $logfile $msg
 
           $user = Get-SPUSER -identity $Account -web $SharepointSiteCollection.url -ErrorAction SilentlyContinue #This will throw an error if the user does not exist
           if ($user -eq $null)
           { #if the user did NOT exist, then we will add them here.
               $SPWeb.ALLUsers.ADD($Account, "", "", "Added by AdminScript")
               $user = Get-SPUSER -identity $Account -web $SharepointSiteCollection.url        
               $msg = "Added user $Account to URL $SPWeb.URL"
               Write-host -Foregroundcolor Magenta $msg
               Add-Content $logfile $msg
           }
            else
           {
                $msg = "user $Account was already in URL " + $SPWeb.URL 
                Write-host -ForegroundColor DarkGreen $msg
                Add-Content $logfile $msg
           }
 
           if ($user.IsSiteAdmin -ne $true)
           {
             $user.IsSiteAdmin = $true
             $user.Update()
             $msg = "$account has been made an admin on $SPWeb.URL"
             Write-host  -Foregroundcolor Magenta $msg
             Add-Content $logfile $msg
           }
           else
           {
             $msg = "$account was already an admin on $SPWeb.URL" 
             Write-host -ForegroundColor DarkGreen $msg
             Add-Content $logfile $msg
 
           }
       }      
 
     $SharepointSiteCollection.Dispose()
  }
 } 
$msg = "=============== ALL DONE ================"
Write-host -ForegroundColor DarkGreen $msg
Add-Content $logfile $msg

 

How to tell what Version/Patch level SCOM is running at

Microsoft System Center Operations Manager 2007 has recently released CU3 (Update 3)
the install proceedure varies depending on what version you have installed.

how can you tell what version you have?
Open the SCOM Console.
Under ‘Monitoring’ select the item ‘Discovered Inventory’
Change the Scope of the items displayed to ‘Heath Service’ (there is a scope button on the tool bar on top)

Grep Equivalent for Windows

Every now and then I need a way to pull all of the lines from a log file that match a certain string.

An example of this would be sharepoint uls logs – every error gets a unique ID number, and the errors can cover 20-30 lines at times.

if all these lines were together, that’d be easy, but often they are not together so a grep like tool comes in handy.

Thanks to a google search and the scripthacks website, it looks like there is a command in windows for this already:

Findstr

http://scripthacks.wordpress.com/2008/09/16/grep-equivalent-for-windows-string-parsing/

Basically, if you open a command prompt and cd to the logs directory,

you can enter something like this:

Findstr “Correlation ID to find” filename

or

findstr “Correlation ID to find” *.log 

 which will look though all the log files in that directory (This can take forever if there are lots of large files)

 Of course you can save the results by adding  > c:\temp\findresults.txt to the end of the line…

 

A handy feature for SharePoint admins with lots of log files might be the /F:file flag

basically, this reads the file list from a file.

Why would you want this?

Because you can easily dump a list of all files to a file with this command:

DIR /B *.log > filelist.txt

once you have this list (mine was 435 lines long!) , you can easily edit it in notepad and reduce the list down to the date range you’re after, this could take you from say, 435 lines down to 24

you’d then do your search with Findstr like this:

Findstr “Correlation ID to find” /F:filelist.txt

Codeplex projects for Sharepoint

Some neat projects exist on codeplex.com that relate to sharepoint

FAST Search Query Analyzer: http://fastforsharepoint.codeplex.com/

Sharepoint content Migration tool: http://spdeploymentwizard.codeplex.com/

Sharepoint Feature Administration and Clean Up Tool: http://featureadmin.codeplex.com/

Sharepoint Farm Report: http://spsfarmreport.codeplex.com/ (an .exe – somewhat jumbled html output)

Sharepoint 2010 Farm Poster http://spposter.codeplex.com/ (some nice Powershell scripts)

 

 

 

2 possible solutions to PDF’s not displaying in browser when served up from SharePoint

I’ve run into this situation a few times and the fix was pretty easy.

The scenario goes like this: A user clicks a PDF file in sharepoint and can’t open it in the browser (instead they have to open it in Adobe Reader)

I’ve seen two fixes for this:
1) involved adding the mime type to the web app – this was a little elusive to me at first – sharepoint keeps tabs on mime types separately than IIS does – I had originally looked in IIS and thought everything was ok..
This can be checked with powershell
$Web = Get-SPWebApplication “http://mysharepointsite.myurl.com”
$Web.AllowedInlineDownloadedMimeTypes – this will list out all the mime types,
if you dont see “application/pdf” in the list, then you can add it like this:
$Web.AllowedInlineDownloadedMimeTypes.Add(“application/pdf”)
$web.Update()

So that was the first approach.

The next approach involved looking at the ‘safe’ settings for a document library – this too was a little elusive, becasue this is generally set at the site collection level – I don’t even think there is an option in the gui to set this for a document library in SharePoint 2010 (RTM) So again it’s gotta be done with powershell

I documented that here:  http://basementjack.com/uncategorized/pdfs-not-openi…oint-2010-site/ ‎

PDF’s not opening in browser from a sharepoint 2010 site?

I had this problem enough times that I wanted to capture the solution.

First of all, credit goes to Craig Lussier on the Technet forms, his post has the full solution and background.

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/2f66404e-5193-46d3-b6b1-45cf72410432?prof=required

I used the above solution and it worked great.

I also found a script that I did not try. The script is described as being able to change this setting system wide by looping through each document library in each subsite of a given site – it could come in handy. (the script is by the same poster – Craig Lussier – Thanks Craig!

http://gallery.technet.microsoft.com/scriptcenter/Set-SPDocumentLibrary-0426781c

The code below is from the first link above, I’ve copied it here in case MS ever changes the link structure and the original post can’t be found. 

# SPAssignment
$gc = Start-SPAssignment

#Get Web
$web = $gc | Get-SPWeb "http://yourspweburl"

#Get Document Library
$docLib = $web.lists["Your Document Library Title"]

#View all properties/methods of the Document Library and you'll see that BrowserFileHandling is a property
$docLib | Get-Member

#See the current BrowserFileHandling setting for the Document Library
$docLib.BrowserFileHandling

#If you need to change it from Strict to Permissive
$docLib.BrowserFileHandling = "Permissive"
$docLib.Update()

# End SPAssgment
$gc | Stop-SPAssignment

Scope Sharepoint FAST search to a file share

Ok this took a bit of wrangling and some new understandings on my part to understand.

I was trying to index a file share of content, and create a FAST search page that would ONLY search that content. Since the FAST server had tons of other stuff on it, I needed to create a scope to narrow down the search. 

I used this powershell command to create the scope – this is key – you can’t do this from the sharepoint GUI (As of Sharepoint 2010 SP)

New-SPEnterpriseSearchQueryScope -SearchApplication “FAST Search Query SSA” -Name thisisthescopename -Description “A scope for a file share” -DisplayInAdminUI 1 -ExtendedSearchFilter “contentsource:nameofcontentsource”

Some explanation – the -SearchApplication is the name of our FAST query SSA – yours might be named differently

The -ExtendedSearchFilter nees some explanation,

First, the word contentsource needs to be in lower case – I had orignally tried it in mixed case (ContentSource) and that didn’t work

Next, the :nameofcontentsource – this is the artificial name you gave the content source over in your FAST Content SSA – it’s NOT the URL, UNC Path etc.. of the content!

for example, if in your FAST Content SSA, you created a content source on \\server1\files and called it myfiles

then your ExtendedSearchFilter would look like this: “contentsource:myfiles”

Ok so that’s the end of my explanation of the command itself.

After a few minutes the scope is created and we can test it in a normal FAST search site in sharepoint

Lets say that we indexed a bunch of content on monkeys and we want to see if it turns up in our new scope.

We would search for scope:thisisthescopename monkey

If we get the results we want, then we know the scope is working.

One step beyond this, we can create a special search page for this scope,

create a new FAST search site in sharepoint.

do a bogus search on the sites home page so that it shows you the results page

Edit the results page in the browser

find the web part at the bottom that displays the results

edit that web part

On the right hand side of the page, are the web parts properties, one of them is ‘scope’

put thisisthescopename in that web part and save the page (don’t forget to check in/publish if needed too)

now on your newly modified search page, when you enter a search for monkey, it will limit it to your scope.

Clear FAST Search Content Collection

I had a stubborn FAST Server installation that continued to return search results, even after the content source was removed from FAST!

After stumbling around, someone on the FAST forums at Microsoft suggested clearing the sp collection, but didn’t say how.

Here’s how:

On the fast server, there will be a shortcut to launch a FAST powershell prompt – open that

Enter the command

Clear-FastSearchContentCollection sp

That should clear it out – you’ll need to do full crawls on all your content sources after this is done to repopulate the index, so it’s best not to do this to a production box without understanding how long search will be down.

Also note that in FAST Search for Sharepoint, pretty much everything is stored in the SP collection – It’s my understanding that as of right now, you can only have one collection in FAST for SP.

Snippet of XSLT to create a link to the parent folder of an item in a search result

I wanted to add a link to the parent folder of an item in FAST search results.

I had found an article that said I could use the “SiteName” property.

Unfortunately, this content wasn’t from a SharePoint site, it was from a File Share.

The “SiteName” only returned \\Server\Sharename for each result, never the folder path

For example \\Server\Share\Folder1\SubFolderA\myfile.txt is where the file is

SiteName retured \\Server\Share

I wanted \\Server\Share\Folder1\SubFolderA\

The following XSLT uses a few chained string commands to return the desired results

<xsl:if test="isdocument = 'True'">
   <br/>
   <a>
      <xsl:attribute name="href">
         <xsl:value-of select="substring(url,1,string-length(url) - string-length(title))"/>
      </xsl:attribute>
      <i>Link to Containing Folder</i>
   </a>
</xsl:if>

Snippet of XLST to dump the output of search results

This is one of those posts more to serve as a reminder to me than anything.

While watching a video on SharePoint-Videos.com about customizing search results with XSLT, the presenter showed how to use a small bit of XSL to dump all the search results returned by the search engine – the original video can be found here: http://www.sharepoint-videos.com/sp10-customize-search-results-using-xslt/

 

<?xml version=”1.0″ encoding=”UTF-8″>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xls:template match "/">
<textarea rows="20" cols="100">
 <xsl:copy-of select="*"/>
</textarea>
</xsl:template>
</xsl:stylesheet>

Using Visifire Charts in Sharepoint with SQL data – Part 1

Visifire.com has a nice silverlight charting library that does animated charts and graphs.

My employer was looking to do up a Dashboard in SharePoint and I used Visifire, the Sharepoint Content Editor Web part and a few back end aspx pages to grab data from various sql servers to present the graphs.

I’m doing a video series on the basics of how to do it.

This first video introduces visifire, downloads some samples and walks through getting the sample to work locally on your PC.

Part 2 will discuss the Visifire Chart Designer.
Part 3 will show how to copy the needed files to SharePoint and how to put the relevant HTML in a SharePoint Content Editor WebPart.
Part 4 talks about how to move Source XAML to a separate file.
Part 5 talks about one way to construct a back end ASPX page to produce the XAML and feed it back.
Part 6 talks about how to modify the ASPX page to query a database and produce live data
Part 7 talks about how to move that page onto the SharePoint Server.

Remove stubborn/stuck computer objects from MS SCOM

I work with a network monitoring tool from Microsoft called System Center Operations Manager (SCOM for short)
The version of SCOM I use (2007 R2 with Fix rollup 2) has an issue that seems to affect computers that are part of a cluster –
The computers could not be deleted, which is a bit of a pain.

This query was provided by a MS support rep, the first query should return a GUID for the object(s) that match the computer name
The second gives you a preview of what you’ll change.
the 3rd actually changes the objects in the database to deleted status.
note that it doesn’t actually delete anything, it just updates the values.

Select TopLevelHostEntityId from basemanagedentity where Name like ‘%ComputerName%’

Select * from basemanagedentity where TopLevelHostEntityId = ‘GUID’

Update BaseManagedEntity Set Isdeleted=1 where TopLevelHostEntityId = ‘GUID’

Powershell notes

I’ve wanted to learn about powershell for a while, but never really had time to mess around with it.
This post will be a collection of key ideas and commands as I read through a book or two on powershell.

#1 Launch powershell:
powershell
#2 Launch powershell ise
powershell_ise
#3 get-childitem
in the powershell command window, hit F7 to bring up a list of recently used commands

commands to get info about commands:
get-Command – (info about command)
get-help *-* (gets info about all commands)
get-help get-* (gets help about all get commands)
get-help set-* (gets help about all set commands)get
invoke-command
measure-command (measure run time)
Trace-command (trace)

Get-hotfix (gets hotfix info)

display environment variables with $env:varname ie $env:computernameget
See the execution Policy: get-ExecutionPolicy
Set the execution policy so it will run anything: Set-ExecutionPolicy

pipeable formatting commands:
format-wide -column 3 (ie Get-command | format-wide -column 3)

Manually download the Juniper VPN client for mac

The new juniper 6.5 client seems work with OSX 10.6.x better than the old ones did – it no longer requires creating a directory and setting permissions from the command line.

That said, my upgrade seemed to go ok, but a few days later, it stopped working – saying it was unable to download files from the URL of my webvpn.

I did an uninstall (I used appdelete) then downloaded the VPN client from the VPN
it turns out the client is easily obtained manually by using
(URL of your webvpn)/dana-cached/nc/NetworkConnect.dmg
this downloads the disk image file, then you can run the setup program from there – once I did that, it worked fine without any further modifications.

(thanks to William (post #9) on http://forums.juniper.net/t5/SSL-VPN/Snow-Leopard-Network-Connect-Fix/m-p/29985)

Changing the server location of checked out Files with Subversion

I recently rebuilt my home domain controller and renamed my home domain that I use internally.

As a result, all the links to my subversion server are now broken.

In other words, my local working copy thinks it’s linked to a subversion server that it can no longer reach.

if only there were a way to update my local copy to let it know where to look…

first I opened terminal (on a mac here, open the cmd prompt on windows)

cd to the working directory

enter svn info – this will display where subversion thinks it’s pointing to

enter svn switch –relocate FROM http://oldpath  TO http://newpath

Video: CODA + Subversion (Beanstalk) How-To

Video: CODA & SUBVERSION HOW TO
I did a video tutorial recently on how to use CODA (A popular mac editor used by web designers) with the Source Control System Subversion (Using Beanstalkapp.com’s free account offering)

The video is just under 20 minutes long and covers:

Setting up a free account on BeanstalkApp.com
How to configure the free account.
How to configure the ‘sites’ tab in Coda to work with the free account.
How to push changes to the Subversion Server (in this case Beanstalkapp)

How to compare an old revision with the current one.

How to ‘roll back’ a code change to an older version that’s in Subversion.

Possible Grid Controls to use with PHP

I’m working on a project in PHP at the moment.

Nothing gets a project moving like dropping a good grid control on  a page, spending 2 minutes setting a few properties and having a nice editable grid.

For ASP.NET, I’ve used the obout.com grid before with pretty good results.

Since this is my first PHP project I thought I’d see what grids are out there.

Here’s what I found…

———————

PlatinumGrid – only works with Delphi – no go.
PHPEzyGrid  -sucked – no inline editing.

KoolPHP.net $130 for the suite – nice flexibility – other tools too (combo box, calendar etc)

AppHP.com’s grid – looks nice – cheap $35

phpgrid.com – requires zend optimizer $99

Active Widgets –  too expensive ($500)

DHTMLX – I like that this is actually a Javascript grid – The  good part about this is that the knowledge gained and the grid itself could be used on other platforms (ie ASP.NET) The bad is that there’s some back end server code that needs to be written. also kind of pricey ($200-450) Typically with a pure Javascript based grid, the back end has to be written 100% by you, however, they have a connector product (still in beta no price given) The nice thing here is that the connector works with php, asp.net and jsp.

eyesis – Does not seem to have the features of other grids (no inline editing)
On the plus side, it does seem very easy to use, so there are likely places where this could be a good fit (last update was Dec 2008 however…)

ExtJS is another javascript control set – they claim to have a bunch of big customers.

It’s not cheap ($330) but like DHTMLx you are buying a whole slew of tools.

One nice thing about ExtJS is that they have a designer tool for it.
They also offer phone support (paid not free)

jQuery Grid (jqGrid) – this is a popular javascript grid for use with the jQuery framework. -$300 per platform (PHP/ASP.net )

datatables.net – (jQuery based – donation based)

SlickGrid (http://github.com/mleibman/SlickGrid)
This is my favorate from an end user perspective for it’s inline editing – it’s just like a spreadsheet.