Followers

Friday 30 October 2015

Use SQL Server PowerShell Provider for Fun and Profit

Source: blogs.technet.com --- Friday, October 30, 2015
Summary : Guest blogger, Mike Fal, talks about leveraging the SQL Server PowerShell provider. Microsoft Scripting Guy, Ed Wilson, is here. Welcome back guest blogger, Mike Fal. He blogged yesterday (see Getting Information from the SQL Server Provider with PowerShell ), and he continues today... In my previous post, I covered how to gather and view data for our SQL Server components by using the SQL Server provider. Gathering this information is simple, just like looking up files in a directory. Being able to grab collection of SQL Server objects and display their properties exposes things quickly and easily for PowerShell users. Using collections with the provider The fact that we are using collections is the second strength of using the provider. Collections are a key element to automation, mostly because we can use them with loops and process them as part of an automated task. We can combine this with the file system of the SQL Server provider, for example, to easily gather and process collections of databases, logins, or other objects. Let’s look at the today’s PowerTip, Use PowerShell to Back Up System Databases. We’re actually dealing with two collections here: the instances and the system databases for each instance. The outer loop steps through each instance in that array—that’s easy enough to understand. Within that, we first use the provider to create a collection of the non-TempDB system databases, then use ForEach-Obj ...



from Microsoft http://ift.tt/1MwYd0s

No comments:

Post a Comment