C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Your Ad Here


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

Understand Powershell in Sql server


Posted Date: 13 Sep 2009    Resource Type: Articles    Category: Databases
Author: R O B I NMember Level: Gold    
Rating: 1 out of 5Points: 12



hello everyone
I think few of us know about

powershell

, so i m introducing here a new feature in sql server usually 2008 Powershell
PowerShell is the .NET based automation engine that Microsoft , it can be embedded into .NET applications but is usually used as a command line shell and scripting language. There has been over 2 million downloads of the PowerShell install package since it became available.
PowerShell install packages are available in 32 bit and 64 bit versions for Windows 2003, Windows XP and Windows Vista. It is an installable feature in Windows Server 2008 i.e. it is part of the operating system install. It is incorporated into a number of Microsoft products including Exchange 2007, a number of System Center products including Operations Manager 2007, Data Protection Manager 2007 and Virtual Machine Manager. A number of third party vendors including Quest, Special Operations Software, SDM software, IBM, Citrix and VMware have produced PowerShell adds for their products or incorporated PowerShell directly into their products. PowerShell is now part of Microsoft’s Common Engineering Criteria and will be incorporated into all major products.

PowerShell has a number of features that need to be understood before working with it:


1)Any PowerShell command will run interactively or in a script. If it can be performed on the command line it can be pasted into a script to be run as required.
2)Cmdlets are small compiled pieces of functionality that provide a single piece of functionality. They have a verb-noun syntax e.g. Get-Help. They are usually named to be as self describing as possible. They are analogous to the utility tools found in the traditional Windows command shell such as ping or ipconfig. Cmdlets output .NET objects rather than the text that more traditional utilities provide.
3)PowerShell, like all good shells, has a pipeline feature. This enables cmdlets to be linked together via a pipeline i.e. the output of one cmdlets is passed into the next cmdlet in the pipeline. As PowerShell is .NET based it means that .NET objects that are passed along the pipeline rather than text.
4)PowerShell is case insensitive by default.
5)Aliases can be defined for PowerShell cmdlets and functions to make a short form of their name available. This can significantly reduce the typing required to construct a line of PowerShell code.
6)PowerShell can utilise ADO.NET to access data in SQL Server.


In the original implementation of SQL Server PowerShell, the following cmdlets are included:


a)To view a list of all cmdlets, type get-command at the shell prompt.
b)To get detailed information about a cmdlet, type get-help CmdletName –detailed where CmdletName is the name of the cmdlet you want to examine.
c)To get detailed information about the SQL Server provider, which provides the SQL Server functionality for PowerShell, type get-help sqlserver

In the script anything that starts with $ is a variable. Using $null when loading the assemblies suppresses the load messages. Setting

$Smo = "Microsoft.SqlServer.Management.Smo."

enables us to reuse this if the script is extended (saves a bit of typing!). SMO is a hierarchy of objects with the server object being the topmost object in the hierarchy. The new-object cmdlet is used to create an instance of the server object. The server object has as a property a collection of the databases on that server. This is accessed as shown on the last line of the script.

$server.databases | Select Name | Format-Table

We pass the collection of databases onto the pipeline. We then select just the database name and then format the data and display in a table. Note that Select is an alias for the Select-Object cmdlet.
We will see the available machines.

cd sql2008

dir

We start by getting the server object. Compare this to how we did it in the script. Get-Item is a standard cmdlet for working with providers. We would use exactly the same cmdlet to access a file in the file system.

$server = get-item default

Once we have the server object we can start to work with it. These are the standard properties exposed in SQL Server. We can see the same properties in the SQL Server Management Studio.





If want to learn powershell then u can understand it by taking help of google
I think that will give u a idea to learn new thing
Thanks



Responses to the resource: "Understand Powershell in Sql server"

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Understand powershell in sql Server 2008  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Hierarchy Data & Hierarchical Tree Layout
Previous Resource: SQL Server 2005 Reporting Services PPT
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
More Resources




About Us    Contact Us    Privacy Policy    Terms Of Use