Share via


The term 'New-SPSite' is not recognized as the name of a cmdlet, function, script file, or operable program

Question

Monday, September 3, 2012 1:54 PM

Hi,

When I try to execute the PowerShell script from the C# code it throughs error "The term 'New-SPSite 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."

My script is

New-SPSite -url 'http://chnmct253594d/sites/TestSite1' -owneralias <'[email protected]'> -ContentDatabase 'WSS_Content' -Description 'Site Provision' -Name 'New Site Request'

Please help me to sort out this issue.

Regards,

Vijay

All replies (3)

Tuesday, September 4, 2012 2:30 AM âś…Answered | 1 vote

Hi,

First,

Add-PsSnapin Microsoft.SharePoint.PowerShell

Then,

New-SPSite -url 'http://chnmct253594d/sites/TestSite1' -owneralias <'[email protected]'> -ContentDatabase 'WSS_Content' -Description 'Site Provision' -Name 'New Site Request'

Regards,

Yan Li

Yan Li

TechNet Community Support


Monday, September 3, 2012 2:14 PM | 1 vote

Add-PsSnapin Microsoft.SharePoint.PowerShell


Monday, September 3, 2012 2:25 PM

Hi,

Thanks for your reply.

I have added the PsSnapin like below. But didnt execute the script.

Add-PsSnapin Microsoft.SharePoint.PowerShell New-SPSite -url 'http://chnmct253594d/sites/TestSite1' -owneralias <'[email protected]'> -ContentDatabase 'WSS_Content' -Description 'Site Provision' -Name 'New Site Request'