Showing posts with label Power Shell. Show all posts
Showing posts with label Power Shell. Show all posts

Friday, April 24, 2015

SharePoint 2010/2013: Trim audit Logs with Powershell

In case that your storage or MSSQL filegroup is full, because  you didn't implement a proper housekeeping of your Audit logs, you can use this PowerShell command to delete them fast:


$site = Get-SPSite https://yoursite.yourdomain.com
$date = Get-Date "20/04/2015"
$site.Audit.DeleteEntries($date)

As the deletion in SQL Server LL happen on a Transaction base it might take a while. Moke sure you have enough free space on your log drive, as the log LL grow and please don't truncate table or apply any operations directly in SQL Server - SharePoint LL not be your friend anymore after such operations! ;-)




Thursday, April 23, 2015

SharePoint 2013: Configure Search Topology with Powershell

The best and the only tool to configure a SharePoint 2013 Search Topology is PowerShell. in my case i had to reconfigure a midsize Server farm with one wfe and an one application Server based classical farm architecture. The script below can also be used to configure a streamlined farm architecture.

 #Define topology variables and assign servernames:

$SPApplication1 = Get-SPEnterpriseSearchServiceInstance -Identity "SEARCHSERVER/APPLICATION"
$SPWFE1 = Get-SPEnterpriseSearchServiceInstance -Identity "WFE"

#Start Search Service Instances on both servers

Start-SPEnterpriseSearchServiceInstance -Identity $SPApplication1
Start-SPEnterpriseSearchServiceInstance -Identity $SPWFE1

#Get services Status / Make sure thate Service is in started state, otherwise don't proceed with configuration and fix issue first.

#Get Search Service Instance status (started or stopped) after running the above commands
Get-SPEnterpriseSearchServiceInstance -Identity $SPApplication1
Get-SPEnterpriseSearchServiceInstance -Identity $hostWF1
#Setting up the topology
$ssa = Get-SPEnterpriseSearchServiceApplication
$newTopology = New-SPEnterpriseSearchTopology -SearchApplication $ssa

#SEARCHSERVER
New-SPEnterpriseSearchAdminComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchCrawlComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1
New-SPEnterpriseSearchIndexComponent -SearchTopology $newTopology -SearchServiceInstance $hostApp1 -IndexPartition 0

#WFE
New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $newTopology -SearchServiceInstance $hostWF1
#Activate the Topology
Set-SPEnterpriseSearchTopology -Identity $newTopology
# Verify the Topology
Get-SPEnterpriseSearchTopology -SearchApplication $ssa

Thursday, August 8, 2013

SharePoint 2013: Standalone installation with local accounts

If u try to install SharePoint without a Domain, u might face the Problem, that SharePoint Products and Configuration Wizard stops with the following error after passing database Access account:

"The specified user MACHINENAME\Username" is a local account. Local accounts should only be used in stand alone mode."

Are we unable to install SharePoint 2013 with local accounts for real? I mean in production this would def. make no sense, but for a development or test Environment it can make sense in certain cases.

The trick here is to precreate the SharePoint_Config database with Power Shell. Use the following command:

> New-SPConfigurationDatabase

This creates all necessary databases and u can run Configuration Manager after with the option “Connect to existing farm”, sure u can successfully setup SharePoint then with local accounts on a single machine.

As this is one of the most time consuming parts of the Setup, u can go for a coffe now. it will take some time...

Friday, January 25, 2013

SharePoint Online: Restore deleted Site Collection - Power Shell

Accidentialy deleted site collections are keept in SharePoint Online recycle bin. The following procedure allows a restore of the complete site collection:

1. Download and Install SharePoint Online Management Shell

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

2. Connect  to SharePoint online

Connect-SPOService [-Url] <UrlCmdletPipeBind> [[-Credential] <CredentialCmdletPipeBind>]
http://technet.microsoft.com/en-us/library/fp161392.aspx

3. Restore the site collection

Restore-SPODeletedSite [-Identity] <SpoSitePipeBind> [-NoWait <SwitchParameter>]
http://technet.microsoft.com/en-us/library/fp161392.aspx


There are more usefull commands to manage site collections in SharePoint online:

http://technet.microsoft.com/en-us/library/fp161400.aspx

Wednesday, October 17, 2012

SharePoint 2010 - Search Suggestions: Add/Remove Terms

Search suggestions are one of the key features of SharePoint 2010 search. One lack of functionality is, that you can manage them only by PowerShell.

Overview Search Suggestions concept: http://sharepointfieldnotes.blogspot.ch/2011/09/sharepoint-2010-search-query.html

Best Script to add suggestions based on a csv file input: http://get-spscripts.com/2010/07/add-pre-query-search-suggestions-with.html

ADD Suggestions (Script from get-spscripts.com):

#Set up default variables
$csvfile="C:\Install\SearchSuggestions.csv"
$ssa = Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" #Create Lists from each item in CSV file
$csvData = Import-Csv $csvfile
foreach ($line in $csvData)
{
New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language en-US -Type QuerySuggestionAlwaysSuggest -Name $line.Suggestion
} $timerJob = Get-SPTimerJob "Prepare query suggestions"
$timerJob.RunNow()


REMOVE Suggestions (modified script from get-spscripts.com):

#Set up default variables
$csvfile="C:\Install\SearchSuggestions.csv"
$ssa = Get-SPEnterpriseSearchServiceapplication -Identity "Search Service Application" #Create Lists from each item in CSV file
$csvData = Import-Csv $csvfile
foreach ($line in $csvData)
{
     Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $ssa -Language en-US -Type QuerySuggestionAlwaysSuggest -Identity $line.Suggestion
} $timerJob = Get-SPTimerJob "Prepare query suggestions"
$timerJob.RunNow()

Note: Search suggestions are added trught the Timer Job "Prepare query suggestions", no reindexing is required after modifications.

Hint: To avoid problems with special characters, please import the CSV as UTF-8. ANSI will end up in unknow special characters.