Archive

Archive for the ‘PowerShell’ Category

Create a list in all the sites using Powershell

September 20, 2011 3 comments

Here is way to create a list based on a custom template using Powershell. The script will go through each site and create the list and add them to the Quick Launch


$GetSites = Get-SPWebApplication | Get-SPSite | Get-SPWeb -Limit ALL
foreach($getsite in $GetSites)
{
$listTemplate = $getsite.Site.GetCustomListTemplates($getsite)
$getsite.Lists.Add("MyList","My List",$listTemplate["MyTemplate"])
$list = $getsite.Lists["MyList"]
$list.OnQuickLaunch = $true
$list.Update()

}

Make sure that custom template is uploaded in the List Template Gallery. Check out this link  if you want to add a list template using powershell

Advertisements

PowerShell Script to loop through all the site collections and backup each Site

February 10, 2011 1 comment

Just change the backup location and script is ready to go.

#Add SNAP-IN

$snapin = Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.SharePoint.Powershell’}

if ($snapin -eq $null)

{

Write-Host “Loading SharePoint Powershell Snap-in”

Add-PSSnapin “Microsoft.SharePoint.Powershell”

}

#Loop through the web application and do a backup of each Site

Get-SPWebApplication | Get-SPSite | Get-SPWeb -Limit All | ForEach-Object{$FilePath = “C:\Backups\” + $_.Url.Replace(“http://”,””).Replace(“/”,”-“) + “.bak” ;

Export-SPWeb -Identity $_.Url -Path $FilePath -Force -NoFileCompression}

Categories: PowerShell, SharePoint

Increase the Default Throttle Size from 2000 for BCS in SharePoint 2010

January 26, 2011 Leave a comment

 

1) Open Microsoft SharePoint PowerShell

a) Go to Start>All Programs > SharePoint 2010 Products >

b) Right Click on SharePoint 2010 Management Shell to open the Powershell as an Administrator.

2) Type the following command:

Command # 1 :

$bdcProxy = Get-SPServiceApplicationProxy | where {$_.GetType().FullName –eq (‘Microsoft.SharePoint.BusinessData.SharedService.’ + ‘BdcServiceApplicationProxy’)}

Command #2 :

Get-SPBusinessDataCatalogThrottleConfig -Scope Database -ThrottleType Items -ServiceApplicationProxy $bdcProxy | Set-SPBusinessDataCatalogThrottleConfig -Maximum 100000000 -Default 500000

Command #3 :


Get-SPBusinessDataCatalogThrottleConfig -Scope Database -ThrottleType Items -ServiceApplicationProxy $bdcProxy

Verify that the output looks like this:

 

Scope : Database

ThrottleType : Items

Enforced : True

Default : 500000

Max : 100000000

Categories: PowerShell, SharePoint Tags: , ,

Tools ‹ Smartrider’s Blog — WordPress

December 28, 2010 Leave a comment

Alerts setup using the Intranet URL will not work for Internet URL in SharePoint

September 29, 2010 Leave a comment

Create the alerts while logged in the application using the Internet URL. Most likely you created the alerts using the internal URL and that’s why the email are showing the internal URL.If you have already created your alerts you can updated them using the PowerShell command:

Invoke-AlertFixup -site <NewURL> -oldurl <OldURL>

Thanks

Smartrider

Categories: PowerShell, SharePoint Tags:

Create new users with unique Passwords in Active Directory using CSV File and PowerShell

September 3, 2010 Leave a comment

Here is simple PowerShell script that can create new accounts and setup unique passwords in Active Directory.

First Step is to create a csv file and specify rows for new accounts For e.g.

UserName,FirstName,LastName,Password,PrincipalName

Second Step is to the script below using PowerShell

$objOU=[ADSI]”LDAP://OU=<OUName>,DC=<test>,DC=<com>”


$dataSource=import-csv “test.csv” //This is the name of the csv file

foreach($dataRecord in $datasource) {


$cn=$dataRecord.FirstName + ” ” + $dataRecord.LastName
$sAMAccountName=$dataRecord.UserName
$givenName=$dataRecord.FirstName
$sn=$dataRecord.LastName
$sAMAccountName=$sAMAccountName.ToLower()
$displayName=$sn + “, ” + $givenName
$Password = $dataRecord.Password
$userPrincipalName=$sAMAccountName + “@test.com”
$emailAddress=$dataRecord.PrincipalName
$objUser=$objOU.Create(“user”,”CN=”+$cn)
$objUser.Put(“sAMAccountName”,$sAMAccountName)
$objUser.Put(“userPrincipalName”,$userPrincipalName)
$objUser.Put(“displayName”,$displayName)
$objUser.Put(“givenName”,$givenName)
$objUser.Put(“mail”,$emailAddress)
$objUser.Put(“sn”,$sn)
$objUser.SetInfo()
$objUser.SetPassword($Password)
$objUser.psbase.InvokeSet(“AccountDisabled”,$false)
$objUser.SetInfo()


}

Last Step is to verify in Active Directory that the accounts are created.