Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, December 22, 2011

New Features in SharePoint 2010

High Level Features in SharePoint 2010:
Sites:
  • Ribbon User Interface
  • SharePoint WorkSpace (Sync Framework)
  • SharePoint Mobile
  • Standard Support
Communities:
  • Rating
  • Inline editing support for Wiki Pages/Blogs
  • RSS Activity Feeds (Similar to Alerts but feed based)
Composites:
  • Business Data Connectivity Services
  • External List
  • Silverlight and AJAX Support
  • Workflow (Site Level and Workflow draft)
  • SharePoint Designer Changes
  • Visual Studio 2010 Support
  • Event receivers enhanced (Site deletion/Web App Provision/Deletion etc.,)
  • User Interfaces
  • API Enhancement - LINQ to SharePoint/ COM & REST/ATOM
Search:
  • Social Relevance and Ranking
  • Phonetic Search (examples B2B etc.,)
  • Better Search Navigation
  • FAST Integration
  • Extensible framework - Search Connector Framework
Insight:
  • Performance Point Services
  • Excel Services
  • Visio Services (Web Browser Support)
  • 2D/3D Chart Web parts
  • SQL Server BI Technologies Integration
  • Power Pivot
Content:
  • Audio/Video content types for streaming
  • Digital Media Assets for DRM (Digital Rights Management)
  • Document Set
  • Tagging/Tag clouds & Taxonomies
  • Social Bookmarking
  • Org Browser
  • Profiles- Other directories integration

Developer Features in SharePoint 2010:
  • Large List Throttling
  • Referential Integrity & Join support to List Columns
  • Event Receivers support to Custom Error Pages
  • Ranking Support
  • Validation Support to List and Columns
  • Event Receiver Post Synchronous Execution Support
  • VS 2010 Projects, Item Templates for Lists/Schema Definitions
  • BDC services support for column definitions
  • Visio Based workflow design support
  • Reusable workflow support
  • Site Workflow support - Capture Site Events
  • VS 2010 Project Item Templates for Workflow Customization of UX
  • Developer Dashboard for Debugging/ Tracing
  • Silverlight Web part Support
  • PowerPoint based Theme Design
  • Theme Preview Support
  • API Enhancements
    • Client Object Model
    • LINQ to SharePoint
    • ADO.NET Data Services/ Web Services/ REST
    • Silverlight Client Object Model
    • ECMA Script library support
  • Application services Architecture (SSP - Not extensible for custom services. Everything or none)
    • Scalable - Shared across farms
    • Extensible
    • On demand basis usage
    • Access Services
    • Business Data Connection Services
    • Excel Calculation Services
    • Metadata Management Services
  • Claims based Authentication Support
  • Unified Logging Services & Correlation ID Support
  • Resource Governance/ Throttling
  • Record Management Features (at Site Collection Level)
  • Multi lingual Support in the same site instead of Variations
  • Audio/Video Content Types – Streaming
  • Document Set
  • Remote Blob Storage Support (for large files)
  • Visio/Excel/Word/Access Webpage
  • Profile Import - Sources Enhanced (AD, LDAP,BDC, Custom)
  • Sandboxed solution deployment support
  • Health Monitoring Support
  • End to End PowerShell Support. More than 500 cmdlets
  • SCOM Management Pack Support

Cumulative Security Update for Internet Explorer 8 in Windows Server 2008 R2 x64 Edition (KB2183461)

SharePoint Server 2007 SDK: Software Development Kit

Update for Microsoft Office Outlook 2007 Junk Email Filter (KB970012)

Windows Internet Explorer 8 for Windows XP

Windows Server 2003 Service Pack 2 (32-bit x86)

DirectX End-User Runtime Web Installer

Windows Imaging Component

Windows XP Service Pack 3 Network Installation Package for IT Professionals and Developers

Windows Search 4.0 for Windows XP (KB940157)

Windows Defender

Microsoft® Windows® Malicious Software Removal Tool (KB890830)

Update for Microsoft Office Word 2007 (KB974631)

The 2007 Microsoft Office Suite Service Pack 2 (SP2)

2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS

Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint File Formats

Wednesday, December 14, 2011

Powershell Scripts for SharePoint

Scheduling SharePoint site backup using stsadm command and batch file

Following stsadm command can be used to take the backup of sharepoint website as a .dat file:
STSADM -o backup -url “http://SiteURL” -filename “C:\SiteBackup.dat"
The above stsadm command takes a backup of only one site collection represented by "http://siteurl".
Recently I worked in a small SharePoint portal which had only one site collection. But there was no database team to take the backup of database. So I needed to take the backup of SharePoint portal some how and schedule it to excute thrice a day automatically.
To achieve the above requirement, I had created a batch file which performs following tasks:
  1. It takes the backup of specified SharePoint site using STSADM command and stores the backup file (.dat file) into the specified directory on the SharePoint server. It follows the naming convention for backup file as "SiteBackup_Date_Time.dat" where Date and Time will be current date & time.
  2. After that it copies the same site backup file into a remote file server "\\RemoteFileServer\SharePoint\Site Backup".
Following is the complete code of the batch file "SharePointBackup.bat":
@ECHO OFF
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe"
for /F "tokens=1-4 delims=/- " %%A in ('date/T') do set DATE=%%B%%C%%D
for /F "tokens=1-4 delims=:., " %%a in ('time/T') do set TIME=%%a%%b%%c
echo Backup Operation Started....
%STSADM% -o backup -url http://siteurl -filename "F:\SharePoint\Site Backup\SiteBackup_%DATE%_%TIME%.dat"
echo Copying Backup File to Remote File Server....
xcopy "F:\SharePoint\Site Backup\SiteBackup_%DATE%_%TIME%.dat" "\\RemoteFileServer\SharePoint\Site Backup"
echo Copying Backup File Completed.
:End
Another requirement was to schedule the SharePoint site's backup to execute thrice a day automatically. To achieve this, I had scheduled this batch file to execute thrice a day using Windows Task Scheduler. To open the Windows Task Scheduler click on "Start -> Settings -> Control Panel -> Scheduled Tasks".

Backup and Restore in SharePoint 2010 using PowerShell

It is essential to have proper backup/restore strategy in place for your SharePoint farms. SharePoint 2010 provides three types of tools for backup/restore for your server farm. The tools are
Central Administration
Windows PowerShell
Stsadm.exe
You need to carefully decide what you are going to backing up and where you are storing these backups. Be noted that SharePoint 2010 doesn’t provide a method to backup directly to tape. SharePoint 2010 backs up to a UNC file share. Technically UNC file share can be anywhere, but it is recommended that you take your backup to a UNC file share in your LAN.
Let me explore each tool available for backup.
Central Administration: You cannot schedule a backup via Central Administration. The primary use of Central Administration backups is to verify the configuration of the target backup location and to back up server farms before major operations. It is recommended to take backup using Central Administration, once you create all web applications and site collections required by your server farm. Also take one backup using Central Administration before any major upgrade of the farm.
Windows PowerShell: The preferred way to take backups in SharePoint Server 2010 is by using windows PowerShell. This method gives you the most options and will be fully supported in the future. You can also schedule the backup using Windows PowerShell.
Stsadm.exe: Stsadm was the command line administration tool available for SharePoint 2007. SharePoint 2010 also provides Stsadm, but it is recommended to use PowerShell as Stsadm is there to offer backward compatibility. Many of the Stsadm commands implemented in SharePoint Server 2010 existed in SharePoint Server 2007. Configuring command-line backups using Stsadm is easy, but it is limited to basic farm backup functionality
In this article I am going to demonstrate the PowerShell commandlets to take various types of backup from SharePoint 2010.
First you need to decide, where you are going to store the backups. Make a UNC share for that location. In order to back up to file share, the following accounts need full permissions to the backup location.
  1. SQL Server service account
  2. SharePoint 2010 Timer Log On account
  3. User account, who is executing the command.
Also you have to ensure that you have enough disk space available for the backup. In the remaining section of this article details the various backup options available to you.

Farm Backup

To back up a server farm using Windows PowerShell, you can use Backup-SPFarm command. The syntax of the command is as follows.
Backup-SPFarm -directory <UNC File Share> -BackupMethod <Full | Differential>
The Backup-SPFarm supports the following options
  • Directory - Defines the backup location previously prepared.
  • BackupThreads - The default thread count is 3. Increasing the thread count will result in faster backup, but it will affect the server performance during backup. Also increasing the threads will make it difficult to check backup logs.
  • ShowTree - Displays the objects in the farm those are available to be backed up. If you use this setting in conjunction with Item, it is scoped to the object underneath Item.
  • ConfigurationOnly – This option specifies to backup only the farm configuration data. No content will be backed up when you specify ConfigurationOnly in the command.
  • Item – You can back up a farm component—such as a Web application, content database, or service application—using the Item parameter. You cannot back up site collections, sites, list, libraries, or list items using the Item parameter.
  • Percentage - You can specify the progress increments on the screen. If scripting, you do not need to use the Percentage option.
  • Force - Using force will bypass the default behavior of halting the backup if the estimator calculates there is insufficient disk space.
  • Verbose – This option will display the progress of the backup in the command line. If this is not presented, you won’t be presented with current progress information.
  • WhatIf - This is a common PowerShell feature, if you specify this option, the command will display the output of running the backup without actually performing the backup.

Restore a Server Farm

The backups taken by PowerShell can be restored by Central Administration. Also it is possible to restore the farm using the PowerShell Script. To restore a farm from backup you can use Restore-SPFarm commandlet.
The UNC share where you configured your backup, may contains more than one backup. So the PowerShell command for restore requires you to specify the backup ID for the backup to restore. No problem, there is a command available to list all the backups available under a UNC share. The command is as follows.
Get-SPBackupHistory -Directory <Backup folder> -ShowBackup [-Verbose]
See the output of the command.
clip_image002
There is another way to find the backup ID, in the root folder of the UNC share used for backup; you can find an xml file named spbrtoc.xml (SharePoint Backup Restore Table Of Contents). To find the ID, open the UNC share in windows explorer, open the spbrtoc.xml in any text editor (e.g. notepad) and you can find all backups with IDs]
The syntax for Restore-SPFarm command is as follows
Restore-SPFarm -Directory UNCShare -BackupId <id of backup>
The Restore-SPFarm supports the following options.
  • Directory - specifies the path to the SharePoint Server 2010 backup location you want to restore from. There must be a valid spbrtoc.xml file in the root of the backup directory.
  • RestoreMethod – Either New or Overwrite. The New option restores the selected backup components and configuration using either new database names or a new SQL Server instance, or both. The Overwrite option restores the content and configuration to the same database instances.
  • BackupId - The unique backup ID you want to restore.
  • ConfigurationOnly - Restores only the farm configuration data, it will not restore any content.
  • Confirm - Requires you to confirm the backup by typing Y, it is just a precautionary option.
  • FarmCredentials - You must supply the farm credentials when restoring content and configuration data.
  • Force – if you want to restore to the existing farm, use this option.
  • Item - Indicates the part of the backup you want to restore. For example, if you have performed a full farm backup, you might choose to only restore a Web application or content database.
  • NewDatabaseServer - If you want to restore to an alternate database server, you can specify that during the restore process.
  • Percentage - You can specify the progress increments on the screen. Percentage complete is seen only when using the Verbose option.
  • RestoreThreads - The default number of process threads is 3. This can be increased to 10 or decreased to 1.
  • WhatIf - Displays the effect of a command without running an actual restore process.
  • Verbose - Displays the output of a command.

Backup web applications using PowerShell

You can use the –item option to the Backup-SPFarm command to back up a particular component in a farm. By specifying the item option with the Backup-SPFarm command, you can backup a web application, a service application or a content database. Also using the Restore-SPFarm command, you can restore any of these.
You can also restore individual items from a full back up without restoring the entire farm backup. So if you are taking full farm backup, it is not necessary to take item wise backups separately.
In order to backup an item, you need to specify the item name you need to backup. To retrieve the item names for backing up, you can use the following command.
Backup-SPFarm –showtree
This command will list the hierarchical items available in the farm. You can retrieve the item name by following the command output.
See the output of the command
clip_image003
To backup a particular item, you can
Backup-spfarm –directory <uncpath> -item “Hierarchical item name” –backupmethod FULL |Differential
e.g.:
Backup-spfarm –directory \\ServerName\UNCShare -item “Farm\ Microsoft SharePoint Foundation Web Application\SharePoint - 2038” –backupmethod FULL
Similarly you can Restore a particular item from a farm backup. See the sample command
Restore-SPFarm –directory <uncpath> -backupid <backup id> -item <item to be backed up>

Backup Site Collection

Sharepoint 2010 supports granular backup and restore. You can backup/restore site collections, individual sites and lists. In this section I am going to cover only the site collection backup.
Windows PowerShell will automatically lock the site collection during backup to reduce the risk of SQL blocking and locking errors. Also it is possible to backup site collection using a SQL snapshot to back up the data. To backup site collections you can use the command Backup-SPSite. The following are the options available for Backup-SPSite.
  • Identity - specifies the URL or GUID of the site collection to back up
  • Path -The full backup path, including the file name.  Here you can use the file path, it is not necessary to specify the UNC path here. 
  • Confirm - Requires you to confirm the backup by typing Y.
  • Force - If you want to overwrite an existing back up file, use the Force option.
  • NoSiteLock - If you want to back up the site collection without making it read-only, use the NoSiteLock option. If you are taking large site collection backups, without a site lock, the back up may fail.
  • UseSqlSnapshot - If you need to back up site collections during the day and require users to continue full read/write operations, you’ll need to create a SQL snapshot to back up from. Using this option creates a temporary SQL Server database snapshot. After the snapshot is created, the backup will be from the snapshot, not the live database. This is the best method to get a full fidelity site collection backup.
  • WhatIf Shows the effects of a command without performing the actual backup
E.G.: Backup-spsite –identity http://win-hgdsnnuakhv/sites/testsite -path c:\sitebkup\mysite.bak

Schedule backups

Once the server farm is up and running, you need to take regular backups. You need to automate the server backup procedure. You need to decide your backup plan. This depends on your farm. You need to carefully decide the backup plan. Also test your back up by restoring it to a test environment, for making sure you are ready for disaster recovery.
Providing a recommendation for backup farm is depends on the implementation. Recently I worked with a farm, where I have 3 site collections in 3 different web applications. I have decided the following backup sets.
  1. Monthly full backup for the entire server farm
  2. Weekly differential backup for the entire server farm
  3. Weekly full backup for each site collection
  4. Daily differential backup for each site collection
Make sure you are taking the decision by carefully considering your back up plans.
Next you need to schedule the scripts. You need to do the following tasks for scheduling the back up.
  1. Create a .ps1 file with your PowerShell commands
  2. Create a batch file that calls the ps1 file
  3. Configure the batch file to execute in certain interval.
The following steps demonstrate scheduling a full farm backup using PowerShell. First create a Windows PowerShell script file with the following contents.
Add-PSSnapin Microsoft.SharePoint.PowerShell
Backup-SPFarm -directory \\win-hgdsnnuakhv\farmbkup -backupmethod FULL
Save this file with extension .ps1. I have named the file as farmfullbkup.ps1.
Now create a batch file, which calls this PowerShell Script. The batch file content is as follows.
PowerShell -command C:\BackupScheduleScripts\FarmFullBkup.ps1
Save this file with extension .bat. In my case, I named the file as FarmFullBkup.bat
Now you can schedule this batch file as you required using Windows task scheduler. In my case I configured this to execute once in a month.

Conclusion

SharePoint provides lot of options for backup/ restore, from a full farm level to list level. Planning for backup / restore in very important in any server farm and you need to carefully decide what backup / restore strategy will help you.


Published
Wednesday, May 18, 2011 1:44 PM
by
sreejukg


Installing SharePoint 2010 on Windows 7 Gotchas

As we approach the Holiday weekend, I suspect many of you will be installing SharePoint 2010 for the very first time… and a good portion of you on Windows 7.
Personally, I found the MSDN article Setting Up the Development Environment for SharePoint Server to be very helpful, and was my main point of reference when I performed the installation But I did have to work my way through several steps that were simply not very clear, and troubleshoot at least one error. In this blog posting, I will help walk you through some of the confusing/unclear steps, and help you overcome (maybe avoid altogether) the error that I encountered.
Note - Remember, this posting assumes that you are following the steps outlined in the MSDN Article: Setting Up the Development Environment for SharePoint Server
Step 1 is strictly geared towards helping you choose your operating system. This posting specifically focuses on installing SharePoint 2010 on Windows 7… remember it must be a 64 bit version and you should have at least 4GB of RAM.
Step 2 is where the confusion begins:
  • The very first sub-step refers to a SharePoint.exe file that for many of us was nowhere to be found. This SharePoint.exe file is actually the single executable contained within the ISO image of the SharePoint 2010 Beta 2 download… for me the file was titled: en_office_sharepoint_server_2010_beta_x64_x16-19249.exe. Depending on the build and version you downloaded, it could have a different name.
  • Copy this file locally (do not run it), they suggest copying it to C:\SharePointFiles
  • Given the complex name I chose to rename it to SharePoint.exe you may consider doing this as well as it makes the following steps easier.
  • The second sub-step instructs you to run a command to extract the installation files. It shows you 2 sample commands, one of which is: c:\SharePointFiles\SharePoint /extract:c:\SharePointFiles
    Here simply replace SharePoint with the name of the executable, the command should work just fine if you’ve renamed the executable to SharePoint.exe
    Examples:
    c:\SharePointFiles\SharePoint.exe /extract:c:\SharePointFiles
    or
    c:\SharePointFiles\OfficeServer.exe /extract:c:\SharePointFiles
    or
    c:\SharePointFiles\en_office_sharepoint_server_2010_beta_x64_x16-19249.exe /extract:c:\SharePointFiles
  • Perform sub-steps 3 to 5 (these should be pretty straight forward)
  • Skip sub-step 6 altogether…it only applies to Vista
  • Install each of the pre-requisites outlined in step 7.
  • Copy the script in step 8 into Notepad and remove all line breaks. It should look something like follows:
    start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-RequestFiltering;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;WCF-HTTP-Activation;WCF-NonHTTP-Activation
  • Copy the script and execute it in the command prompt. (I suspect you may receive several errors during this step if some of the services are missing or have already been preconfigured) Sub-step 9 should help you troubleshoot any errors you encounter during the activation of these services.
  • Restart your computer and on to Step 3.
Step 3 is pretty straight forward and should not give you much of a headache as long as you follow the instructions. There is a required hotfix, which they didn’t list in the instructions… I’ll get to it shortly:
  • Know that you must choose “Standalone” configuration in sub-step 3. If you run into errors after choosing “Server Farm”, you are on your own.
  • Stop on sub-step 5 and install SQL Server 2008 KB 970315 x64 per the instructions. But do not run the Configuration Wizard just yet.
  • Download and run the WCF hotfix from http://go.microsoft.com/fwlink/?LinkID=166231. If you don’t you will receive an exception while running the Configuration Wizard (more details on the error here and here.)
  • Run the SharePoint Configuration Wizard.
Steps 4 and 5 instruct you to install Visual Studio 2010 and Create a Hyper-V virtual hard disk from the installation.
It would be a shame for you to leave out installing SharePoint Designer 2010 Beta 2.
That should be it… Have fun coding with Visual Studio 2010 and SharePoint 2010.

digg_url = “http://blog.rafelo.com/2009/11/installing-sharepoint-2010-on-windows-7.html”;digg_title = “Installing SharePoint 2010 on Windows 7 Gotchas (What SharePoint.exe?)”;digg_bgcolor = “#FFFFFF”;digg_skin = “compact”; digg_url = undefined;digg_title = undefined;digg_bgcolor = undefined;digg_skin = undefined;

Installing SharePoint 2010 on Windows 7

Installing SharePoint 2010 on Windows 2008 is a breeze with the new included Farm Setup Wizard, however installing it under Windows 7 is another story.
I approached SharePoint 2010 the old way, try and see, planning to write a post on how to install SharePoint 2010 on Windows 7, and then realized that Microsoft have promised that with this version the documentation will be here so I tried the MSDN and there it is, a step by step instruction available here: http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx
The following steps are based on the public beta for SharePoint 2010. So in short what you need to do is:
  1. Extract the SharePoint files into a folder.
  2. Modify the config.xml to be able to install it on Windows 7 by including the <Setting Id="AllowWindowsClientInstall" Value="True"/> tag.
  3. Install prerequisites:
  4. Enable all the necessary windows features using this script.
  5. Reboot your computer (this step is very important don’t skip it otherwise you might get errors when running the configuration wizard).
  6. Install SharePoint 2010 from the extracted folder.
  7. When you are prompted to run the Configuration Wizard, don’t.
  8. Install SQL Server 2008 KB 970315 x64.
  9. Install FIX FOR: WCF: SharePoint Shared Services Roll-up
  10. Now you can run the Configuration Wizard.
  11. Install Visual Studio 2010 Beta 2 Professional.
  12. Download and install the Microsoft SharePoint 2010 SDK.
If you plan to install the Office Web Application again you will need to extract the files then modify the config.xml to allow the Windows 7 installation by including <Setting Id="AllowWindowsClientInstall" Value="True"/> tag.

Tuesday, December 13, 2011

Command Prompt ShourtCuts for Windows

Control Panel

  • CONTROL: opens the control panel window
  • CONTROL ADMINTOOLS: opens the administrative tools
  • CONTROL KEYBOARD: opens keyboard properties
  • CONTROL COLOUR: opens display properties.Appearance tab
  • CONTROL FOLDERS: opens folder options
  • CONTROL FONTS: opens font policy management
  • CONTROL INTERNATIONAL or INTL.CPL: opens Regional and Language option
  • CONTROL MOUSE or MAIN.CPL: opens mouse properties
  • CONTROL USERPASSWORDS: opens User Accounts editor
  • CONTROL USERPASSWORDS2 or NETPLWIZ: User account access restrictions
  • CONTROL PRINTERS: opens faxes and printers available
  • APPWIZ.CPL: opens Add or Remove programs utility tool
  • OPTIONALFEATURES: opens Add or Remove Windows component utility
  • DESK.CPL: opens display properties. Themes tab
  • HDWWIZ.CPL: opens add hardware wizard
  • IRPROPS.CPL: infrared utility tool
  • JOY.CP: opens game controllers settings
  • MMSYS.CPL: opens Sound and Audio device Properties. Volume tab
  • SYSDM.CPL: opens System properties
  • TELEPHON.CPL: Opens phone and Modem options
  • TIMEDATE.CPL: Date and Time properties
  • WSCUI.CPL: opens Windows Security Center
  • ACCESS.CPL: opens Accessibility Options
  • WUAUCPL.CPL: opens Automatic Updates
  • POWERCFG.CPL: opens Power Options Properties
  • AZMAN.MSC: opens authorisation management utility tool
  • CERTMGR.MSC: opens certificate management tool
  • COMPMGMT.MSC: opens the Computer management tool
  • COMEXP.MSC or DCOMCNFG: opens the Computer Services management tool
  • DEVMGMT.MSC: opens Device Manager
  • EVENTVWR or EVENTVWR.MSC: opens Event Viewer
  • FSMGMT.MSC: opens Shared Folders
  • NAPCLCFG.MSC: NAP Client configuration utility tool
  • SERVICES.MSC: opens Service manager
  • TASKSCHD.MSC or CONTROL SCHEDTASKS: opens Schedule Tasks manager
  • GPEDIT.MSC: opens Group Policy utility tool
  • LUSRMGR.MSC: opens Local Users and Groups
  • SECPOL.MSC: opens local security settings
  • CIADV.MSC: opens indexing service
  • NTMSMGR.MSC: removable storage manager
  • NTMSOPRQ.MSC: removable storage operator requests
  • WMIMGMT.MSC: opens (WMI) Window Management Instrumentation
  • PERFMON or PERFMON.MSC: opens the Performance monitor
  • MMC: opens empty Console
  • MDSCHED: opens memory diagnostics tools
  • DXDIAG: opens DirectX diagnostics tools
  • ODBCAD32: opens ODBC Data source Administrator
  • REGEDIT or REGEDT32: opens Registry Editor
  • DRWTSN32: opens Dr. Watson
  • VERIFIER: opens Driver Verifier Manager
  • CLICONFG: opens SQL Server Client Network Utility
  • UTILMAN: opens Utility Manager
  • COLORCPL: opens color management
  • CREDWIZ: back up and recovery tool for user passwords
  • MOBSYNC: opens Synchronization center
  • MSCONFIG: opens System Configuration Utility
  • SYSEDIT: opens System Configuration Editor (careful while using this command)
  • SYSKEY: Windows Account Database Security management (careful while using this command)

Windows utility and applications

  • EPLORER: Opens windows Explorer
  • IEXPLORER: Opens Internet explorer
  • WAB: opens Contacts
  • CHARMAP: opens Character Map
  • WRITE: opens WordPad
  • NOTEPAD: opens Notepad
  • CALC: opens Calculator
  • CLIPBRD: opens Clipbook Viewer
  • WINCHAT: opens Microsoft Chat Interface
  • SOUNDRECORDER: opens sound recording tool
  • DVDPLAY: run CD or DVD
  • WMPLAYER: opens Windows Media Player
  • MOVIEMK: Opens untitled Windows Movie Maker
  • OSK: opens on-screen Keyboard
  • MAGNIFY: opens Magnifier
  • WINCAL: opens Calendar
  • DIALER: opens phone Dialer
  • EUDCEDIT: opens Private Character Editor
  • NDVOL: opens the mixer volume
  • RSTRUI : opens Tool System Restore (For Vista only)
  • %WINDIR%\SYSTEM32\RESTORE\rstrui.exe: opens Tool System Restore (for XP only).
  • MSINFO32: Opens the System Information
  • MRT : launches the utility removal of malware.
  • Taskmgr : Opens the Windows Task Manager
  • CMD: opens a command prompt
  • MIGWIZ: Opens the tool for transferring files and settings from Windows (Vista only)
  • Migwiz.exe: Opens the tool for transferring files and settings from Windows (for XP only)
  • SIDEBAR: Open the Windows (Vista only)
  • Sigverif : Opens the tool for verification of signatures of files
  • Winver : Opens the window for your Windows version
  • FSQUIRT: Bluetooth Transfer Wizard
  • IExpress opens the wizard for creating self-extracting archives. Tutorial HERE
  • MBLCTR: opens the mobility center (Windows Vista only)
  • MSRA : Opens the Windows Remote Assistance
  • Mstsc : opens the tool connection Remote Desktop
  • MSDT: opens the diagnostic tools and support Microsoft
  • WERCON: opens the reporting tool and solutions to problems (for Vista only)
  • WINDOWSANYTIMEUPGRADE: Enables the upgrade of Windows Vista
  • WINWORD : opens Word (if installed)
  • PRINTBRMUI : Opens migration wizard printer (Vista only)

Disk management

  • DISKMGMT.MSC: opens disk management utility
  • CLEANMGR: opens disk drive clean up utility
  • DFRG.MSC: opens disk defragmenter
  • CHKDSK: complete analysis of disk partition
  • DISKPART: disk partitioning tool

Connection management

  • IPCONFIG: list the configuration of IP addresses on your PC (for more information type IPCONFIG/? in the CMD menu)
  • INETCPL.CPL: opens internet properties
  • FIREWALL.CPL: opens windows firewall
  • NETSETUP.CPL: opens network setup wizard

Miscellaneous commands

  • JAVAWS: View the cover of JAVA software (if installed)
  • AC3FILTER.CPL: Opens the properties AC3 Filter (if installed)
  • FIREFOX: Mozilla launches Firefox (if installed)
  • NETPROJ: allow or not connecting to a network projector (For Vista only)
  • LOGOFF: closes the current session
  • SHUTDOWN: shut down Windows
  • SHUTDOWN-A: to interrupt Windows shutdown
  • %WINDIR% or %SYSTEMROOT%: opens the Windows installation
  • %PROGRAMFILES%: Opens the folder where you installed other programs (Program Files)
  • %USERPROFILE%: opens the profile of the user currently logged
  • %HOMEDRIVE%: opens the browser on the partition or the operating system is installed
  • %HOMEPATH%: opens the currently logged user C: \ Documents and Settings \ [username]
  • %TEMP%: opens the temporary folder
  • VSP1CLN: deletes the cache for installation of the service pack 1 for Vista
  • System File Checker (Requires Windows CD if the cache is not available):
    • SFC / scannow: immediately scans all system files and repairs damaged files
    • SFC / VERIFYONLY: scans only those files system
    • SFC / Scanfil = "name and file path": scans the specified file, and repaired if damaged
    • SFC / VERIFYFILE = "name and file path": Scans only the file specified
    • SFC / scanonce: scans the system files on the next restart
    • SFC / REVERT: return the initial configuration (For more information, type SFC /? In the command prompt CMD.

Tuesday, December 06, 2011

Doing Some Operation If User is Having Admin Priviledges to the Site...!

 try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPWeb currentWeb = SPContext.Current.Web;
                    if (currentWeb.CurrentUser.IsSiteAdmin)
                    {
                        writer.Write("Logged User is Having Admin Permissions to the Site...!");
                    }

                });
            }
            catch (Exception ex)
            {
                writer.Write(ex.ToString());
            }

Getting the Group of the Currently Logged User

try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPWeb currentWeb = SPContext.Current.Web;
                    foreach (SPGroup grp in currentWeb.CurrentUser.Groups)
                    {
                        if (grp.ID == 4)
                        {
                            writer.Write("User Logged in is an Administrator");
                            break;
                        }

                        if (grp.ID == 6)
                        {
                            writer.Write("User Logged in is an Contributor");
                        }
                    }

                });
            }
            catch (Exception ex)
            {
                writer.Write(ex.ToString());
            }

Monday, December 05, 2011

Configuring the User Profile Service in SharePoint 2010 with Images available in this post.

Configure profile synchronization in SharePoint Server 2010

User Profile Service Administration

Get data from bcs external content type in SharePoint 2010 Programmatically

Here is short example of how to execute a method on an entity Programmatically. Assuming you already have a External content type “My External content type” setup to a Sql database lets look at a console application
private static void ExecuteMethod()
{
Console.WriteLine(“\nNow Executing methods”);
using (SPSite site = newSPSite(siteUrl))
{
using (newSPServiceContextScope(SPServiceContext.GetContext(site)))
{
BdcService service = SPFarm.Local.Services.GetValue();
IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);
IEntity entity = catalog.GetEntity(siteUrl, “My External content type”);
ILobSystemInstance LobSysteminstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;
IMethodInstance method = entity.GetMethodInstance(“Read List”, MethodInstanceType.Finder);
IEntityInstanceEnumerator handle = entity.FindFiltered(method.GetFilters(), LobSysteminstance);
Console.WriteLine(“Title in My External content type:”);
while (handle.MoveNext())
{
Console.WriteLine(handle.Current["Title"].ToString());
}
}}}

Access BCS entities and methods Programmatically SharePoint 2010

This post we will see an example for accessing Business Connectivity Services or BCS entities and its methods using Client object model.
Assumptions – Already have an External content type setup
private static void BrowseCatalogDetails()
{
Console.WriteLine(“Now Browsing the all the entities in the catalog:”);
AdministrationMetadataCatalog catalog = AdministrationMetadataCatalog.GetCatalog(siteUrl);
EntityCollection entities = catalog.GetEntities(“*”, “*”, true);
Console.WriteLine(“\nEntities in the system:”);
foreach (Entity entity in entities)
{
Console.WriteLine(entity.Name);
}
// Browsing through the first entity
var entityEnum = entities.GetEnumerator();
entityEnum.MoveNext();
Entity firstEntity = entityEnum.Current;
Console.WriteLine(“\nMethods on the first Entity:”);
foreach (var method in firstEntity.Methods)
{
Console.WriteLine(method.Name);
}
}
The above code is to access the SharePoint entity catalog. To get a specific entity use
IEntity entity = catalog.GetEntity(siteUrl, “MyexternalContentType”);

What is Business Connectivity Services in SharePoint ?

SharePoint 2010 provides a new set of technologies known as Business Connectivity Services for retrieving, editing, updating, and deleting data from external systems(for e.g. data from ERP or CRM database). BCS enhances the SharePoint platform’s capabilities with out-of-box features, services and tools that streamline development of solutions with deep integration of external data and services.

Getting Current Page Url using xslt.

<%@ Page language="C#" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" masterpagefile="~masterurl/default.master" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content id="Content1" runat="Server" contentplaceholderid="PlaceHolderMain">
<script language="javascript" type="text/javascript">
function getLinkDynamic()
{
 var strUrl="/{@FileRef}/DispForm.aspx?ID={@ID}&Source=window.location.href";
 return strUrl
}
</script>
    <WebPartPages:SPProxyWebPartManager runat="server" id="ProxyWebPartManager">
    </WebPartPages:SPProxyWebPartManager>
    <table style="width: 100%">
        <tr>
            <td>
            <WebPartPages:WebPartZone id="g_946A9FBBB7644CEFB36BBE70340D9A15" runat="server" title="Zone 1"><ZoneTemplate>
            <WebPartPages:DataFormWebPart runat="server" SuppressWebPartChrome="False" Description="" PartImageSmall="" DataSourceID="" MissingAssembly="Cannot import this Web Part." ListName="{53175A92-E6CC-4464-8E5C-9C23436D0577}" FrameType="None" ConnectionID="00000000-0000-0000-0000-000000000000" DetailLink="" ExportControlledProperties="True" IsVisible="True" AllowRemove="False" AllowEdit="False" ID="g_6b7417ff_0b73_40ae_84bc_152313e9a2cd" Dir="Default" FrameState="Normal" DisplayName="Test" ViewContentTypeId="" AllowClose="False" AllowConnect="False" PageSize="-1" Default="FALSE" AllowMinimize="False" IsIncludedFilter="" ShowWithSampleData="False" ChromeType="None" HelpMode="Modeless" ExportMode="All" ViewFlag="0" Title="Test" HelpLink="" AllowHide="False" AllowZoneChange="False" PartOrder="1" UseSQLDataSourcePaging="True" PartImageLarge="" IsIncluded="True" NoDefaultStyle="TRUE" __MarkupType="vsattributemarkup" __WebPartId="{F3F8B212-E809-47FE-952C-E01E98F22F81}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><DataSources>
<SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;/View&gt;" UseInternalName="True" ID="Test1"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{53175A92-E6CC-4464-8E5C-9C23436D0577}" Name="ListID"></WebPartPages:DataFormParameter>
</SelectParameters><UpdateParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{53175A92-E6CC-4464-8E5C-9C23436D0577}" Name="ListID"></WebPartPages:DataFormParameter>
</UpdateParameters><InsertParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{53175A92-E6CC-4464-8E5C-9C23436D0577}" Name="ListID"></WebPartPages:DataFormParameter>
</InsertParameters><DeleteParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{53175A92-E6CC-4464-8E5C-9C23436D0577}" Name="ListID"></WebPartPages:DataFormParameter>
</DeleteParameters>
</SharePoint:SPDataSource>
</DataSources>
<ParameterBindings>
             <ParameterBinding Name="ListID" Location="None" DefaultValue="{53175A92-E6CC-4464-8E5C-9C23436D0577}"/>
             <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
             <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
             <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
             <ParameterBinding Name="url_PATH_INFO" Location="ServerVariable(PATH_INFO)" DefaultValue=""/>
             <ParameterBinding Name="url_HTTP_HOST" Location="ServerVariable(HTTP_HOST)" DefaultValue=""/>
            </ParameterBindings>
<DataFields>@Title,Title;@Description,Description;@ID,ID;@ContentType,Content Type;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;</DataFields>
<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="url_PATH_INFO" />
<xsl:param name="url_HTTP_HOST" />
<xsl:variable name="CurrentPageUrl" select="concat('http://',$url_HTTP_HOST,$url_PATH_INFO)" />
 <xsl:output method="html" indent="no"/>
 <xsl:decimal-format NaN=""/>
 <xsl:param name="dvt_apos">'</xsl:param>
 <xsl:variable name="dvt_1_automode">0</xsl:variable>
 <xsl:template match="/">
  <xsl:call-template name="dvt_1"/>
 </xsl:template>
 <xsl:template name="dvt_1">
  <xsl:variable name="dvt_StyleName">Table</xsl:variable>
  <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
  <table border="0" width="100%" cellpadding="2" cellspacing="0">
   <tr valign="top">
    <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
     <th class="ms-vh" width="1%" nowrap="nowrap"></th>
    </xsl:if>
    <th class="ms-vh" nowrap="nowrap">Title</th>
    <th class="ms-vh" nowrap="nowrap">Description</th>
   </tr>
   <xsl:call-template name="dvt_1.body">
    <xsl:with-param name="Rows" select="$Rows"/>
   </xsl:call-template>
  </table>
 </xsl:template>
 <xsl:template name="dvt_1.body">
  <xsl:param name="Rows"/>
  <xsl:for-each select="$Rows">
   <xsl:call-template name="dvt_1.rowview"/>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="dvt_1.rowview">
  <tr>
   <xsl:if test="position() mod 2 = 1">
    <xsl:attribute name="class">ms-alternating</xsl:attribute>
   </xsl:if>
   <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
    <td class="ms-vb" width="1%" nowrap="nowrap">
     <span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
    </td>
   </xsl:if>
   <td class="ms-vb">
    <a href="/{@FileDirRef}/DispForm.aspx?ID={@ID}&amp;Source={$CurrentPageUrl}" target="_blank"><xsl:value-of select="@Title" /></a></td>
   <td class="ms-vb">
    <xsl:value-of select="@Description"/>
   </td>
  </tr>
 </xsl:template>
</xsl:stylesheet> </Xsl>
</WebPartPages:DataFormWebPart>
</ZoneTemplate></WebPartPages:WebPartZone></td>
        </tr>
    </table>
</asp:Content>

Adding a content database using PowerShell in SharePoint 2010

Adding a content database using PowerShell in SharePoint 2010
To attach an existing content database:

Mount-SPContentDatabase "<ContentDb>" –DatabaseServer "<DbServer>"
–WebApplication http://WebapplicationName

<ContentDb> is the content database to be attached.

<DbServer> is the name of the database server.

http://WebapplicationName is the name of the Web application to which
the content database is being attached.

To detach a content database:

Dismount-SPContentDatabase "<ContentdBName>"

Where is the name of the content database.

How to list all the commands in PowerShell ?

Get-Command * commands gets you all the Powershell commands.

Permissions for Windows PowerShell - SPShellAdmin

Permissions for Windows PowerShell - SPShellAdmin
In order to use Windows PowerShell for SharePoint 2010 Products, a
user must be a member of the SharePoint_Shell_Access role on the
configuration and content database. In addition to this, the user must
also be a member of the WSS_ADMIN_WPG local group on the computer
where SharePoint 2010 Products is installed.

To add a user as SharePoint_Shell_Access on the SharePoint database
use the below powershell cmdlet :

Add-SPShellAdmin

Please Note that to run the above cmdlet you must have
* Membership in the securityadmin fixed server role on the SQL Server instance
* Membership in the db_owner fixed database role on all affected databases
* and local administrative permission on the local computer.

In addition to above some important things to Note:

* The user gets added to the WSS_Admin_WPG group on all Web servers
when the user is added to the SharePoint_Shell_Access role.

* If the target database does not have a SharePoint_Shell_Access role,
the role is automatically created.

* If you use the database parameter, the user is added to the role on
the farm configuration database, the Central Administration content
database, and the specified database. Using the database parameter is
the preferred method because most of the administrative operations
require access to the Central Administration content database. The
cmdlet is something like below :

Add-SPShellAdmin -UserName Domainname\User -database {Database GUID}

If you need going to install a webpart or any custom solution in SharePoint 2010 using PowerShell What permissions do you need?

If you need going to install a webpart or any custom solution in SharePoint 2010 using PowerShell What permissions do you need?
In order to use Windows PowerShell for SharePoint 2010 Products, a user must be a member of the SharePoint_Shell_Access role on the configuration and content database. In addition to this, the user must
also be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint 2010 Products is installed.

Where is Powershell located in sharePoint ?

On the Start menu, click All Programs -> Click Microsoft SharePoint 2010 Products -> Click SharePoint 2010 Management Shell.

Can you Create PowerShell scripts for deploying components in SharePoint ?

If you are creating a webpart with VS 2010 then you can deploy it using ctrl + f5. However, to activate the webpart feature you can write a powershell script (.ps1) and execute it after dpeloyment.

What are CMDLets?

Windows PowerShell introduces the concept of a cmdlet which are simple build in commands, written in a .net language like C# or VB.

How is Windows Powershell different from Stsadm ?

Unlike stsadm, which accept and return text, Windows PowerShell is built on the Microsoft .NET Framework and accepts and returns .NET Framework objects. In addition to that it also gives you access to the file system on the computer so that you can access registry,digital signature certificate etc..

What is windows PowerShell?

Windows PowerShell is a new Windows command-line shell designed especially for system administrators. In the SharePoint administration context, Windows PowerShell is another administration tool that supersedes the existing Stsadm.exe.

SharePoint 2010 Windows PowerShell Commands Part2

Some more PowerShell Commands

Site Collection Commands

Create Site Collection :

Get-SPWebTemplate
$template = Get-SPWebTemplate "STS#0"
New-SPSite -Url "" -OwnerAlias "" -Template $template

Delete Site Collection :

Remove-SPSite -Identity "URL of site Collection" -GradualDelete

Change Site collection Quotas :
Set-SPSite -Identity "SiteCollection Url" -MaxSize Quota

Add site Collection Administrators :


Set-SPSite -Identity "" -SecondaryOwnerAlias ""

Lock or unlock a site collection :

Set-SPSite -Identity "Site Collection Url" -LockState ""

is one of the following vales :

# Unlock: To unlock the site collection and make it available to users.

# NoAdditions: To prevent users from adding new content to the site collection. Updates and deletions are still allowed.

# ReadOnly: To prevent users from adding, updating, or deleting content.

# NoAccess: To prevent access to content completely. Users who attempt to access the site receive an access-denied message.

Create a site :


New-SPSite "http://sitecollection/sites/Subsite -OwnerAlias "DOMAIN\UserName" –Language 1033

SharePoint 2010 Windows PowerShell Commands - Part1

To Open the Windows PowerShell Session :

1. On the Start menu, click All Programs.

2. Click Microsoft SharePoint 2010 Products.

3. Click SharePoint 2010 Management Shell

Note : You should have SharePoint_Shell_Access role on the configuration database and you should be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint Server 2010 is installed.


Some of the Common Commands and Operations are:


Create Web Application Variable

$webapp = Get-SPWebApplication "http://WebapplicationUrl"


Create SharePoint Site Variable (Instance of SPSite)

$siteurl = "http://MySharePointSite"

$Oursite=new-object Microsoft.SharePoint.SPSite($siteurl)

Here we have created a variable Oursite, which contains an instance of type SPSite. Now you can use it to display all webs in the site collection.

$Oursite.AllWebs more // List all Webs in the Site


Create Service Application Variable

$spapp = Get-SPServiceApplication -Name "ServiceApplicationDisplayName"


Create a Webapplication:

New -SPWebApplication -ApplicationPoolName <Name of the application pool> -Name <Name of the new Web application> [ -Port <Port on which the Web application can be accessed>] [-HostHeader <Valid URL assigned to the Web application that must correlate to the alternate access mapping configuration>] [-URL <Load-balanced URL for the Web application>][ -ApplicationPoolAccount <User account that this application pool will run as>]

Delete WebApplication


Remove-SPWebApplication –identity -URL <http://sitename> -Confirm


Create\Delete a Site Collection:


Create a Site collection:

Get-SPWebTemplate

$template = Get-SPWebTemplate "STS#0"

New-SPSite –Url "<URL for the new site collection>" –OwnerAlias "<domain\user>" –Template $template

Here $template is a Variable to store the type of template we want to use while creating a site collection.

Delete a Site Collection:

Remove-SPSite –Identity <URL> –GradualDelete

Here <URL > is a site Collection Url .



Back\Restore a content database

To Backup :

Backup -SPFarm -Directory <Backup folder> -BackupMethod -Item <Content database name> [-Verbose]

Backup folder - is a folder to save your backup.

BackupMethod – Can Specify between Full or Differential.


To Restore:

Restore -SPFarm -Directory <Backup folder> -RestoreMethod Overwrite -Item <Content database name> [-BackupId] [-Verbose]

If you don’t know the BackupID you can display all the backups using the below command and get the GUID of the Backup.

Get-SPBackupHistory -Directory <Backup folder>

You can check all the Backup-Restore Operations Here


Deploy WebPart Soluiton Package

Install -SPWebPartPack -LiteralPath "PathToCABorwspFile" -Name "NameOFWebPart"

PathToCABorwspFile- is the full path to the CAB file that is being deployed.

NameOFWebPart- is the name of the Web Part that is being deployed.


Install Activate and Deactivate Feature using Windows Powershell


Install Feature :

$MyFeatureId = $(Get -SPFeature -limit all where {$_.displayname -eq "myfeatureName"}).Id

Install -SPFeature $MyFeatureId


Activate\Enable Feature :

$singleSiteCollection = Get -SPSite -Identity http://MySingleSiteCollectionURL

Enable -SPFeature $MyFeatureId -Url $singleSiteCollection.URL


Deactivate\Disable Feature :

$singleSiteCollection = Get-SPSite -Identity http://MySingleSiteCollectionURL

Disable -SPFeature $MyFeatureId -Url $singleSiteCollection.URL


Command TO List all the PowerShell Commands
Get-Command –PSSnapin “Get-Command –PSSnapin “Microsoft.SharePoint.
PowerShell” format-table name > C:\SP2010_PowerShell_Commands.txt

Check in documents with Powershell SharePoint 2010

A simple script shared at @ http://secretsofsharepoint.com/cs/ site for Checking in the documents in a document library using a powershell script.
function CheckInDocument([string]$url)
{
$spWeb = Get-SPWeb $url
$getFolder = $spWeb.GetFolder(“Shared Documents”)
$getFolder.Files | Where { $_.CheckOutStatus -ne “None” } | ForEach
{
Write-Host “$($_.Name) is Checked out To: $($_.CheckedOutBy)”
$_.CheckIn(“Checked In By Administrator”)
Write-Host “$($_.Name) Checked In” -ForeGroundColor Green
}
$spWeb.Dispose()
}
Here’s an example on running the function:
CheckInDocument http://SP

SharePoint 2010 PowerShell Permissions Explained

SharePoint 2010 has increased flexibility for administrative privileges of command line operations.  The end result is that there is a bit more complexity in setting up your administrative privileges, so I wanted to create a post to try and clear up administration permissions for SharePoint 2010. 
Foremost, please keep in mind that I’m going to discuss the minimum required privileges for each role—so there are lots of additional configurations; this is the just bare requirements.
First we need to talk about Central Administration, as the different permissions often lead to confusion.  To access Central Administration, you need to be a Farm Administration—aka, a member of the “Farm Administrators Group”.  This is really a UI only permission (I recommend you think of “Farm Adminstration Privs” as “The ability to use Central Admin”.  The reason for this is that Farm Administrators have the ability to run operations via-the Central Administation Web Application; keep in mind that no operation actually runs against the Configuration Database as the user but rather as the App Pool account for the Web App.
With STSADM and PowerShell, all commands are run as the user who executes the command (not through the Central Admin Web Application).  The good part about this is that any command can be run from any machine (no CA required), but this means that the user themselves needs the proper permissions.  With STSADM, the user required Box, Farm, and SQL permissions—way too much to run a truly “Least Privs” environment.  With 2010 there is the flexibility to only require PowerShell & SQL permissions*. 
                *Note: Box permissions are required for a small subset of commands that touch the Windows filesystem or registry.  Also, Box and SQL are required for all “setup” operations.
On that note, there are only two requirements for most commands.  The user must be:
·         A member of the WSS_ADMIN_WGP group (this is a Windows Group on the machine the user is executing commands on)
·         A member of the “SharePoint_Shell_Access” role on the configuration database (this is a SQL Role)
To simplify the management of these roles we have created a set of PowerShell commands (noun is “SPShellAdmin”) to add and remove Shell Administrators.  You’ll notice that the commands allow you to designate a specific database, this is because the “Shell Admin” role by default only gives the user access to the Configuration Database; the shell admin must be given access to each individual service and content database they are “allowed to manipulate” (i.e.: to delete a content database, the user must be a shell admin on that database).
                *IMPORTANT: The Shell Admin commands in SharePoint 2010 Beta do not fully setup these roles; you need to add the WSS_ADMIN_WGP role manually.
Please keep in mind that each command is just running object model, so additional permissions may be required for specific commands.  For example, you may need Service Application permissions to run commands against a certain service application.
Hopefully I’ve made permissions a little easier to understand—but if you’ve still got questions, put them in the comments section below.

Run a SharePoint PowerShell Backup Script using Windows Scheduler

SharePoint administrators need to run regular backups using PowerShell, the STSADM tool or in Central Administration. There is no "built in" way to automate these backups. Wouldn't it be great to devise a method to automate these jobs.
The solution is just to create a batch file that can execute a PowerShell script, and then launch it from the Windows Task Scheduler.

PowerShell Command to Backup SharePoint Site Collection

backup-spsite -identity http://moss2010/ -path D:\Backup\Backup.bak
So, you can use the backup-spsite command to do site backup (the example shows http:// moss2010 /). The following script will start a full backup to D:\backup where you can send a site collection URL and backup file name as a parameter to the PowerShell Script.
$args[0] = http://moss2010/ [Source site location URL] 
$args[1] = D:\backup\backup_site.bak [Destination path] 

Create Windows PowerShell script

Add-PSSnapin Microsoft.SharePoint.PowerShell 
backup-spsite -identity $args[0] -path $args[1] -force
Save it as PowerShell D:\Scripts\BackupSPSite.ps1

Create Batch Script to execute PowerShell script

@echo off
SET SOURCE_SITE=http://moss2010/ 
SET DEST=D:\backup\Backup_site.bak
echo "backup Started at" %DATE% >> D:\backup\Log.txt
powershell -command D:\Scripts\BackupSPSite.ps1  %SOURCE_SITE% %DEST%
echo "Backup completed successfully at %DEST%" on %DATE% >> D:\backup\Log.txt
@echo on
Save it as Batch file D:\Scripts\BackupSPSite.bat. Now you have to run this script.

Run Batch Script to execute PowerShell script

  • Run batch script to check successful backup and log creation at D:\backup.
  • Now run it from the Windows Task Scheduler. In the Task Scheduler, the account needs to be set with admin permissions to run it properly.
So now you can automate your daily backup of a SharePoint Site. You can also run an entire Farm backup just by using the following command in a PowerShell Script (i.e. D:\Scripts\BackupSPSite.ps1)

Get files from document library Silverlight client object model

Get files from document library Silverlight client object model
Here is a detailed code snippet for creating a silverlight applictaion that will display all the files\documents from a document library in a webpart using silverlight Client Object model.
To begin with
1. In Visual Studio 2010 create a new Blank Solution. Select .NET Framework 3.5.
2. Next, from the File menu open click on Add -> New Project.
3. In the New Project dialog box, expand the Installed Templates left hand menu to Visual C# -> Silverlight, and choose the Silverlight Application project type in the project type list in the middle section of the screen. Make sure that you have .NET Framework 3.5 selected. Click Ok to continue on Silverlight Application dialog box.
4. Next, add the required references to the Silverlight client object model. To do this browse to “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin” and select Microsoft.SharePoint.ClientSilverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll
5. In the solution explorer open the App.xaml.cs and add the following references to the top of the page.
using Microsoft.SharePoint.Client;
using System.Threading;
6. Next in the same file App.xaml.cs, under Applictaion_Startup method add the below to get the refrence to the current sharepoint site and to ensure that we are in sync with the current SharePoint site.
ApplicationContext.Init(e.InitParams, Synchronizationcontext.Current);
7. Next, lets open up our MainPage.xaml and Add two StackPanels under the existing grid.
<StackPanel Orientation=”Vertical” VerticalAlignment=”Top”>
<StackPanel Name=”mypanel” />
</StackPanel>
8. Now, Open MainPage.xaml.cs and add the following using statements to the top of the file:
using Microsoft.SharePoint.Client;
9. Next, add the following code to get all the files from your SharePoint document library in the silverlight webpart.
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
ClientContext clientCtx;
Microsoft.SharePoint.Client.List docs;
int FileCounter= 0;
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
{
clientCtx = new ClientContext(ApplicationContext.Current.Url);
clientCtx.Load(clientCtx.Web);
clientCtx.Load(clientCtx.Web.Lists);
docs = clientCtx.Web.Lists.GetByTitle(“My Documents”);
clientCtx.Load(docs);
clientCtx.Load(docs.Rootfolder);
clientCtx.Load(docs.Rootfolder.Files);
clientCtx.ExecuteQueryAsync(loadSiteData, null); // We will move to loadSiteData method on success
}
void loadSiteData(Object sender, ClientRequestSucceededEventArgs e)
{
//This method starts on a background thread, but we need to work on UI to display our files Therefore we call Dispatcher.BeginInvoke() to perform the UI updating on the main thread
Dispatcher.BeginInvoke(addFiles);
}
void addFiles()
{
foreach (File doc in docs.Rootfolder.Files)
{
clientCtx.Load(doc);
clientCtx.ExecuteQueryAsync(addFiletoUI, null); // We will move to loadSiteData method on success
}
}
void addFiletoUI(Object sender, ClientRequestSucceededEventArgs e)
{
Dispatcher.BeginInvoke(addFile);
}
void addFile()
{
string filename = docs.Rootfolder.Files[FileCounter].Name;
string fileUrl = docs.Rootfolder.Files[FileCounter].ServerRelativeUrl;
HyperlinkButton fLink= new HyperlinkButton();
fLink.Content = filename;
fLink.NavigateUri = new Uri(fileUrl , UriKind.Relative);
mypanel.Children.Add(fLink);
FileCounter++;
}
}
10. Build and deploy the webpart.
11. Goto SharePoint site and add a silverlight webpart. Point the webpart to “”/_layouts/ClientBin/YourSilverlightApp_Name.xap” and your Done! yeh!

How do you access ECMAScript object model API’s

The ECMAScript library is available in a number of JS files in the LAYOUTS folder. The main file among number of .js files is SP.js. When you include this file in the APSX page using a ScriptLink control, all other required JS files are loaded automatically. By linking SP.js to your page, the SP namespace gets registered. SP is the SharePoint namespace that contains all objects. For debugging purposes every js file also has a ‘debug’ equivalent in the same folder.

InfoPath 2010 Basics

Infopath 2010 form drop-down list change event get data programmatically

Infopath 2010 form drop-down list change event get data programmatically
A short code snippet to get the data from a datasource on change event of a drop-down list in Infopath 2010 form.
In the code below the method InternalStartup() is called to register the event change for the dropdown and the method mydropdown_Changed() is called to access the actual datasource “MyDATASOURCE” for retrieving the values for Field1 or sharepoint Title column from the sharepoint list datasource(MyDATASOURCE).
The parameter passed to the Datasource via the webservice is ID of the drop-down item.
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
namespace Getdatanamespace
{
public partial class FormCode
{
public void InternalStartup()
{
EventManager.XmlEvents["/my:myform/my:table1/my:mydropdown"].Changed += new XmlChangedEventHandler(mydropdown_Changed);
}
public void mydropdown_Changed(object sender, XmlEventArgs e)
{
XPathNavigator form = MainDataSource.CreateNavigator();
// Set parameter for web service request and query connection
DataSources["MyDATASOURCE"].CreateNavigator().SelectSingleNode(“/dfs:myFields/dfs:queryFields/q:SharePointListItem_RW/q:ID”,NamespaceManager).SetValue(e.NewValue); ->> sending the ID as a parameter to the webservice call which will access the datasource
DataSources["MyDATASOURCE"].QueryConnection.Execute();
// Create navigator on web service response
XPathNavigator resultnav = DataSources["MyDATASOURCE"].CreateNavigator();
// Set fields with values from web service response
XPathNavigator Field1 = form.SelectSingleNode(“/my:myform/my:table1/my:field1″, NamespaceManager);
Field1.SetValue(resultnav.SelectSingleNode(“/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Title”,NamespaceManager).Value);
}
}
}