Home > Deployment, ITPro, PowerShell, SharePoint 2010 > PowerShell Code Snippets for SharePoint2010 Developers

PowerShell Code Snippets for SharePoint2010 Developers

#Install Admin Approved InfoPath form 


#Please specify the template path.

$InfopathFormTemplatePath = "C:\ybbest\myForm.xsn"

#Please specify the site collection url.

$SiteCollectionUrl="http:// ybbest /"

#Install InfoPath to the SharePoint Farm

$formTemplate=Install-SPInfoPathFormTemplate -Path $InfopathFormTemplatePath

#Activate InfoPath form to Site Collection

Enable-SPInfoPathFormTemplate -Identity $formTemplate -Site $SiteCollectionUrl

# Add .Net Framework Windows Feature Using PowerShell


Import-Module ServerManager
Add-WindowsFeature NET-Framework
Add or Remove a computer from Domain
Add-Computer -domainname ybbest; Rrestart-Computer
Remove-Computer -credential ybbest\beny -force; Restart-Computer

#Pre-Deployment command script to recreate the site collection

stsadm -o deletesite -url <a href="http://ybbest">http://ybbest</a>
stsadm -o createsite -url <a href="http://ybbest">http://ybbest</a> -owneremail beny@ybbest.com -ownerlogin ybbest\beny -sitetemplate STS#1 -title "ybbest Team"

#Create SharePoint site collection using PowerShell

You can download deployment script here.

#Scripts to deploy solution

You can download deployment script here.

#Scripts to add user to SharePoint Group

You can download script here.

#Scripts to import documents to SharePoint document library

You can download script here.

#Scripts to Create Managed Path

You can download script here.

#Scripts to Create Managed Properties

You can download script here.

#Scripts to Hide certain fields on item new and edit form

You can download script here.

#Scripts to create list and library with custom content types.

You can download script here.

References

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

http://www.wssdemo.com/Lists/PowerShell/Commands.aspx

http://www.sharepointproconnections.com/article/sharepoint/Create-a-SharePoint-Site-Collection-with-Windows-PowerShell-UI-Style.aspx

http://www.devexpertise.com/2009/02/06/sharepoint-list-template-ids-and-site-template-ids/

Deploying SharePoint 2010 Solution Package Using PowerShell (Revisited)

Advertisements
  1. February 10, 2013 at 8:40 pm

    excellent post, very informative. I wonder why the other specialists of this sector don’t understand this. You should proceed your writing. I’m sure, you’ve a great readers’
    base already!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: