Tuesday, December 23, 2014

Run a PowerShell script in windows scheduler

Once I had a client requirement to run a PowerShell script for a SharePoint 2010 web application to download web analytic reports in a scheduled time. This is how I scheduled the automation of PowerShell script

1.       Go to task scheduler
2.       Click in “Create Task”

3.       Give a name to the task
“Generate Web Analytic Reports”

4.       In Triggers tab, give the date and time which need to Schedule the task


5.       In Actions tab add a new Action
·         Select the Action as “Start a program”
·         In “Program/Script” text box give the following path


C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

·         In “Add Arguments (optional)” text box add following


-psconsolefile "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\psconsole.psc1" -command "C:\ShawCor\WebAnalitics\Reports.ps1"


Report.ps1 is the PowerShell script which I need to run

·         Then click OK

Click Ok to set the task scheduler. The script will run at the given date and time.

Monday, December 22, 2014

Activate the “SharePoint 2010 User Code Host” service.

Activate Sandbox Solutions


From SharePoint 2010 top-level site, logged in as a Site Collection Administrator do the following:

  • Click Site Actions à Site Settings.
  • Under Galleries, choose Solutions.
  • Under the Solutions tab, click Upload Solution. Browse to .wsp package and click OK.
  • Click the Activate button to activate the solution in the site collection. 

If the Activation Button is disabled we need to activate the “SharePoint 2010 User Code Host” service.

Activate “SharePoint 2010 User Code Host” service


Following are the steps to activate “SharePoint 2010 User Code Host” service:

1.       From Central Admin à Security à Configure Service Account



2.       select the Windows Service - Microsoft SharePoint Foundation Sandboxed Code Service option from the drop down and add the account which need to activate the service




3.       After configuring the service account for Sandbox, navigated to “Central Admin à Application Management à Manage Services”




4.       Start the service “Microsoft SharePoint Foundation Sandboxed Code Service”.





5.       Navigate to services and check for the service “SharePoint 2010 User Code Host” had started.





User Profile Synchronization in SharePoint 2010

In following steps I have described how to set up User Profile Synchronization in SharePoint 2010

Service Applications

Service Applications are individual services that can be configured independently and can be shared across other sites within the farm or across farms.


Create User Profile Service Applications


Bellow I have described 2 ways of configuring service applications

1.       Configure service applications through Farm configuration wizard

In Central Admin, under farm configuration, click on Launch the Farm configuration wizard

                There we can select and automatically configure all service applications

2.       Configure service applications manually

1.       Go to central admin à Application Management à Manage Service Applications


2.       Click on Newà User Profile Service Application


3.       Give a name and other properties for the User Profile Service Application

4.       There are 3 databases created in this step

·         Profile DB– Stores user information and activity feed
·         Social DB– Stores tags and notes
·         Sync DB– Staging area for FIM while it’s syncing between AD and SharePoint

If we go and check in SQL server there we can see 3 databases which created in above step

Start the User Profile Synchronization service


After creating the user profile service application we need to start the “User Profile Synchronization Service”

1.       Go to Application Managementà manage services on Server

2.       Start following services


Configure connections and import data from directory services


Create a synchronization connection to a directory service


To import user profiles from Active Directory we need to create a synchronization connection

  1. Go to Central Administration àApplication Management à Manage service applications.
  2. Click on User Profile service application.
  3. On the Manage Profile Service page, in the Synchronization section, click Configure Synchronization Connections.
  4. On the Synchronizations Connections page, click Create New Connection.
  5. On the Add new synchronization connection page, type the synchronization connection name in the Connection Name box 
  1. Select a directory service From the Type list, which you want to connect. 
  1. Fill in the Connection Settings section according to the directory service to which you are creating a connection 
  1. Select the Container and click OK. Then the connection will be created


Define exclusion filters for a synchronization connection


To import user profile information of user accounts that are enabled in Active Directory to SharePoint Server 2010, follow these steps: 

1.     On the Synchronization Connections page, click the Active Directory connection that you want to edit, and then click Edit Connection Filters.



2.     On the Edit Connection Filters page, follow these steps:

In the Exclusion Filter for Users section do following

a.     In Exclusion Filter for Users, change the Attribute drop-down to userAccountControl.
b.     In Exclusion Filter for Users, change the Operator drop-down to Bit on equals.
c.     Select Filter box type to 2.
d.     Click Add.



3.     Click OK.

 

Start profile synchronization


Go to Manage Profile Service page. There in right hand side we can see the profile details. The Number of user profiles are 0. We need to start profile synchronization service.


1.     On the Manage Profile Service page, in the Synchronization section click “Start Profile Synchronization”



2.     Select Start full Synchronization and click OK

We can see the synchronization has started





From couple of minutes if you refresh the page we can see the “Number of user profiles” are changed.


References