Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Saturday, December 13, 2014

Local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

One of my newly joined team member was getting this error on his powershell editor. Following has been done to fix this.

Log on to the DB server choose the SharePoint Config DB -> provide the user with the following membership SharePoint_Shell_Access and db_owner. 

Hope this helps you!!!

Monday, October 6, 2014

PowerShell - Microsoft SharePoint is not supported with version 4.0.30319.18063 of the Microsoft .Net Runtime - Resolved

We tried to Install SPDiag 3.0 for our SharePoint environment, which provides SharePoint administrators with a unified interface that can be used to gather relevant information from a farm,

It also displays the results in a meaningful way, to identify performance issues, and share or export the collected data and reports.


When we tried to create a project , it was throwing the following error.




The error message was " Microsoft SharePoint is not supported with version 4.0.30319.18444 of the Microsoft .Net Runtime".

I did try to change the Psconfig.exe.config to point to .Net 2.0 and it did not solve the problem. So finally decided to uninstall Microsoft Windows Management framework 3.0 from installed windows updates.

After uninstalling , things started working. Hope this helps you.


Sunday, September 28, 2014

Format Commands for PowerShell Output .

I was trying to get the list of timer jobs and their frequency in a table format using powershell. I searched technet and after reading through this  I figured it out.

I tried Get-SPTimerJob |Format-Table -Wrap   -AutoSize -property name,schedul
e,description,webapplication > D:\Timerjobs.txt.

Somehow the output text file showed only the name of the timerjobs with the following message

"WARNING: 3 columns do not fit into the display and were removed."

After a subtle thought I used the following command and got the results in a way I wanted.

Get-SPTimerJob |Format-Table -Wrap  -property name,schedul
e,description,webapplication > D:\Timerjobs.txt

Another interesting parameter you might want to use is ConvertTo-HTML , which will create a HTML report .

Get-SPTimerJob |ConvertTo-HTML -property name,schedul
e,description,webapplication > D:\Timerjobs.htm

Hope this helps you.

Saturday, September 20, 2014

The term 'get-spfarm' is not recognized

I was using Windows Poweshell - ISE for creating some power shell scripts and got the following error.

"get-spfarm : The term 'get-spfarm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

Checked the PowerShell Code and found that I forgot to add powershell snapin and added the following and the script got executed.

Add-PSSnapin "Microsoft.SharePoint.PowerShell" 

Tuesday, September 16, 2014

Merge ULS Logs to find Correlation ID

There was an issues in the BCS settings of my SharePoint 2010 farm and I need to search for a particular message in my farm. I had to login each searver of my farm search through the ULSLogs to find a specific error message.

I did want to find a shortest route for this and found the Merge-SPLogFile Power Shell that will merge all the logs from your farm to a specific directory depending on the parameters.

This will take some time to execute, and at the end you will have the ULS Logs at  one place , which can be used to skim through the errors.

Hope this helps you.



Monday, September 15, 2014

Powershell to find Orphaned Databases

To get a list of orphaned databases : Get-SPDatabase | where {$_.exists -eq $false}

To delete the orphaned databases : Get-SPDatabase | where {$_.exists -eq $false} | foreach {$_.delete()}

Hope this helps you

Thursday, August 28, 2014

Powershell Command to get List Schema.xml in ClipBoard

Please use the following Power Shell command

$web = Get-SPWeb XXXX
$list= $web.lists[Your Lists]
$list.Fields.SchemaXml | clip


Monday, May 5, 2014

Restoring a site collection in SharePoint 2010

I was trying to restore a site collection in a web application. I usually create a site collection manually and then restore it using Restore -SPSite command with Force option. Today I wanted to try with out creating a site collection manually and by executing the Restore-SPSite http://server_name/sites/site_name -Path \\file_server\share\site_name.bak powershell command

It worked and i was able to see a site collection was created!!!