Maximo's profileMax - Put It TogetherPhotosBlogListsMore Tools Help

Maximo Trinidad

Occupation
Location
Interests
I’m from Puerto Rico and living in Florida since 1992. I Have work with computers since 1979. In 2009, finally got my Microsoft MVP in PowerShell and move to a new .NET Programmer/Analylist position with a new company.
Microsoft Community Sites
Most valuable resource links
There are no photo albums.

Max - Put It Together

October 21

Connect to a remote SQL Server using SQLPS.

 

Displaying a list of tables with their rows count:

1. You need to have installed an instance of SQL Server 2008 (or 2008 R2) in order to use SQLPS.

2. To connect to another SQL Server remotely, you need to make sure the server(s) are properly registered in your SQL Management Studio (2008/2008-R2). Look in the *“Registered Servers” pane.

*Hint: You should be able to query SQL Server 2000, and 2005.

clip_image002

3. To start using SQLPS, there’s three ways to open it:

  • a. In the Windows Start/Search box, typing SQLPS and then Enter.

image

  • b. SQL Management Studio, right-click on any of the objects and look for “Start PowerShell”

image

image

4. Start SQLPS session:

clip_image004

5. Check your SQL Registered Servers:

clip_image006

6. Here’s a very useful one-liner cmdlet to get tables –rowcounts and generate some output:

 

# - Change directory to the database ‘RemoteSQL01’ – tables folder:

CD SQLSERVER:\sql\RemoteSQL01\default\databases\NewDB\tables

dir | Select name, rowcount | FT -auto

Name             RowCount

----                       --------

Table1                         0

Table2                        86

Table3                      107

#- or send the result to a *.csv file

dir | Select name, rowcount | Export-Csv -NoTypeInformation C:\temp\RowCount.csv

ii C:\temp\RowCount.csv #-To open file in Excel

The first line use the “CD” to change directory to the remote server tables folder. Then, use the “dir” to list all tables. If you need to find more information about that folder then use the “Get-Member” (or the alias “gm”) so you can see that properties and methods you have available at your finger tips.

Example, use the following approach to save the results on a variable and then use “Get-member”:

 

CD SQLSERVER:\sql\Mtrinidad-01\default\databases\developer\tab

# – Change directory to:

PS SQLSERVER:\sql\Mtrinidad-01\default\databases\developer\tables>

dir

Schema Name Created

------ ---- -------

dbo Accounts 4/15/2009 1:48 PM

dbo Accounts - Local 8/6/2009 1:10 PM

:

# – Create variable x to hold “dir” results

$x = dir

$x | gm | more

TypeName: Microsoft.SqlServer.Management.Smo.Table

Name MemberType Definition

---- ---------- ----------

:

Alter Method System.Void Alter()

:

Create Method System.Void Create()

:

Drop Method System.Void Drop()

:

Name Property System.String Name {get;set;}

:

RowCount Property System.Int64 RowCount {get;}

 

Then, using the Cmdlet “Select” (short for “Select-Object”), you can work with the properties: “Name” and “RowCount” to be displayed in the PowerShell Console:

dir | Select name, rowcount

Results:

image 

Have fun with SQLPS!!

October 18

Microsoft PowerShell Team stepping up with more tools for PowerShell…

Microsoft PowerShell team have only giving a more complete PowerShell and including a scripting editor included in their latest OS’s.  But now, there’s two interesting tools emerging for those venturing deeper in PowerShell scripting:

1. “PowerShell Cmdlet and Help Designer” by the Microsoft PowerShell Team:

Brief description:

The Cmdlet Designer makes it much easier for teams to concentrate on the design, naming, and consistency of their cmdlets, while also guaranteeing name registration and collision avoidance across a project.

Download at: http://cmdletdesigner.codeplex.com/

2. “PowerShellpack” by one the Microsoft PowerShell Team member – James Bundage:

Brief description:

Windows PowerShell Pack contains 10 modules to help supercharge your Windows PowerShell scripting. The PowerShellPack lets you write user interfaces in PowerShell script, manage RSS feeds, schedule operating system tasks, and much more.

Download at: http://code.msdn.microsoft.com/PowerShellPack

Good job guys!!

SQLSaturday #21 – Orlando – PowerShell and SQLServer Sessions was a great success…

Special Thanks to Andy Warren for allowing both me and Chad to present our PowerShell SQL Part 1 and 2 at this Awesome event.

Here’s some pictures:

Here’s downloads for both sessions:

1. PowerShell and SQL Server part 1: http://cid-a034d6a0ddc4e64e.skydrive.live.com/self.aspx/SQLSaturday21%5E_10172009%5E_Demo/SQLSaturday21%5E_10172009.zip

2. PowerShell and SQL Server Administration part 2: http://chadwickmiller.spaces.live.com/blog/cns!EA42395138308430!562.entry

Here’s THE PHOTO of the Florida PowerShell Power Leaders ( Only SW Florida – Jeff Truman is missing in this picture ):

100_0571

From left to right: Buck Woody (MS Seattle, WA), Ron Dameron (Tampa), Chad Miller (Tampa), and me – Max Trinidad.

Thanks to all attendees and organizers for having us!!

October 16

FLPSUG – FLorida PowerShell User Group Meeting (10/29/2009)…

FLPSUG - Florida PowerShell User Group

flpsugnwlogo1

Starts:
Thursday October 29, 2009 at 6:00pm

Ends:
Thursday October 29, 2009 at 8:00pm

Event Type:
Training/Seminar

Region:
Miami/Fort Lauderdale Area

Location:
New Horizons
100 S Pine Island Rd
Fort Lauderdale, FL 33324 US

Price:

Website:
http://www.flpsug.com

Industry:
computer software

Intended For:
developer, system administrator, database administrator, DBA, and any one who want to now about automation technology.

Organization:
Florida PowerShell User Group

Maximo Trinidad, Microsoft MVP, is the Florida PowerShell User Group's founder and leader. He is truly passionate about sharing his knowledge of PowerShell with others.

Meetings: tentative on 3rd Wednesday of every month (change of dates are possible)

Website: http://www.FLPSUG.com

Blog: http://max-pit.spaces.live.com

Twitter: MaxTrinidad

PowerShell V2 Launch Party - please help get the word out…

From one of the MVP’s:

Windows isn’t just about the GUI. Starting with Windows 7, you have built-in access to PowerShell version 2, an object-oriented scripting language and command shell. Please join PowerScripting Podcast hosts Jonathan Walz and PowerShell MVP Hal Rottenberg as they interview Distinguished Engineer Jeffrey Snover on launch day! Jeffrey is the chief architect responsible for PowerShell at Microsoft, and he’ll be covering what’s new with the tool and why every system administrator on the planet needs to be using it. If you’ve never attended PowerScripting Live, you are missing out on a great time. The show will be streamed live via Ustream, and viewers can chat with each other, as well as submit questions for the guest.

· When: Thursday, October 22nd, 9:30 PM EDT (GMT-4)

· Where: PowerScripting Live on Ustream, and follow the blog and podcast atPowerScripting.net

Please join us in this GREAT DAY!!

Thanks Hal for all the hard work!!