Posted by Scott on July 24, 2011
In the SharePoint 2010 Information Worker, the FASTSearchCert deployed in the image expired in April 2011 and needs to be updated.
The following script (credit to Bryan Hart) will update the certicate in a single elevated PowerShell prompt.
###################################
# Apply Certificate to FAST
###################################
write-host "Applying Certificate to FAST" -ForegroundColor Yellow
Add-PSSnapin AdminSnapIn
Add-PSSnapin Microsoft.FASTSearch.PowerShell
Add-PSSnapin Microsoft.SharePoint.PowerShell
stop-service FAST*
$installerdir = $env:FASTSEARCH + "installer\scripts"
cd $installerdir
$pw = ConvertTo-SecureString -AsPlainText -force pass@word1
.\ReplaceDefaultCertificate.ps1 -generateNewCertificate $true -certificatePassword $pw
$cert = @(dir cert:\LocalMachine\My -recurse | ? { $_.Subject -eq 'CN=FASTSearchCert' })[0]
$thumb = $cert.Thumbprint
Start-service FAST*
.\SecureFASTSearchConnector.ps1 -certThumbprint $thumb -ssaName "FASTContent" -username "contoso\administrator"
Reference
Posted by Scott on July 21, 2011
I recently had an interesting situation come up where a Governance committee (you have one right?) decided to alter their document versioning guidelines. The current policy dictated that all documents had both major/minor versioning. The new policy stated that the organization would be moving to a major versioning only scheme.
With thousands of document libraries in an established farm, the prospect of visiting thousands of List Settings pages was not at all appealing. PowerShell to the rescue.
The Script
The following script accepts a parent web and enumerates all of its children (optional), altering the libaries that match the criteria “Not a System/Style/Hidden library” and “has minor versioning currently enabled”. The matching libraries are updated to force document checkouts and accept an unlimited numer of major versions (Governance decision, no listening to reason there).
function Reset-SPDocumentLibaries {
param (
[string] $WebUrl = $(Read-Host -prompt "Enter a Url"),
[switch] $ProcessChildren
)
$web = Get-SPWeb $WebUrl;
ProcessWeb $web $ProcessChildren;
}
function ProcessWeb($web, $processChildren) {
Write-Host "Processing Web",$web.Title,"(",$web.Url,")" -foregroundcolor "Green";
$lists = @($web.Lists | Where-Object { ($_.BaseType -eq "DocumentLibrary") -and ($_.BaseTemplate -eq "DocumentLibrary") -and ($_.IsSiteAssetsLibrary -eq $false) -and ($_.EnableMinorVersions -eq $true) -and ($_.Hidden -eq $false) -and ($_.Description -notlike "*system*") -and ($_.Description -notlike "*style*") })
if ($lists.Count -gt 0) {
foreach ($list in $lists) {
if ($list.Title.Length -gt 0) {
Write-Host " Processing List",$list.Title -foregroundcolor "Green";
$list.EnableVersioning = $true;
$list.EnableMinorVersions = $false;
$list.MajorVersionLimit = 0;
$list.ForceCheckout = $true;
$list.Update();
}
else {
Write-Host " Invalid List Encountered" -foregroundcolor "Red"
}
}
} else {
Write-Host " No lists matching filter were found" -foregroundcolor "Red"
}
if ($processChildren) {
foreach ($subWeb in $web.Webs) {
ProcessWeb $subWeb $processChildren
}
}
}
Posted by Scott on June 21, 2011
A recent client engagement had us flipping back and forth between the v3 and v4 UI (Visual Upgrade) for a number of site collections in a given content database.
The PowerShell function outlined below allows for setting the UIVersion on all of the site collections and sites in a given content database in one shot.
function Set-SPUIVersion(
[string]$dbName = $(Read-Host -prompt "Content Database Name"),
[int32]$uiVersion = $(Read-Host -prompt "UI Version"))
{
$db = Get-SPContentDatabase $dbName
foreach ($s in $db.Sites) {
foreach ($w in $s.AllWebs) {
$w.UIversion = $uiVersion;
switch ($uiVersion) {
3 { $w.UIVersionConfigurationEnabled = $true; }
4 { $w.UIVersionConfigurationEnabled = $false; }
}
$w.Update();
}
}
}
Posted by Scott on April 11, 2011
The following PowerShell script allows for saving all of the farm level solutions in a SharePoint 2010 farm.
The Script
function SPGetFarmSolutions {
param (
[string] $directory = $(Read-Host -prompt "Enter a directory (use ""."" for current dir)")
)
if ($directory.Length -lt 2) {
$directory = [string]$pwd + "\\";
}
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local;
$solutions = $farm.Solutions;
$solutions | ForEach-Object {
Write-Host "Found solution $_.name";
$_.SolutionFile.SaveAs($directory + $_.name);
}
}
or the one liner:
(Get-SPFarm).Solutions | ForEach-Object{$var = (Get-Location).Path + "\" + $_.Name; $_.SolutionFile.SaveAs($var)}