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 and currently exposed to the latest programming .NET technologies. I had been a Senior IT Pro/Developer providing support to Windows 2003 Servers, i5, and SQL Servers 2000/2005 applications in both physical and virtual environment. In 2009, finally got my Microsoft MVP in PowerShell and move to a new .NET Programmer/Analylist position in a new company.
Microsoft Community Sites
Most valuable resource links
There are no photo albums.

Max - Put It Together

July 04

Virtual Varia Blog: More PowerShell in R2 tricks

Take a look at this blog about using Powershell in Windows Server R2 virtualization environment.  This is good stuff,

Click here: (Virtual Varia : More PowerShell in R2 tricks)

:)

July 03

Executing SQLPS scripts from your SQLPS/PowerShell Window

I’ve seen many good SQLPS scripts on the internet but they asked you to copy/paste the code into the prompt. Then during my “PowerShell and SQL Server” presentation, I realized there’s a better way to stop doing copy/pasting code.  I already got it saved to my scripts folder and the only thing I need to do is running from the SQLPS prompt.

So, how can we do this?

I – From SQL Server Management Studio

 clip_image002

1. At the SQLPS prompt, Type the location of your Script Repository:

clip_image004

2. Now you can type the Script name and press enter. You can use the “tab expansion” to auto filled your script name.

clip_image006

clip_image008

II - Run “SQLPS” from within PowerShell Windows

1. Open Windows PowerShell Console prompt, then run SQLPS.exe or

2. Use the WindowsPowerShell user profile to include SQLPS.exe at the end of the script.

clip_image010

The following SQLPS script will create a table Employee in a NewDB database.

clip_image012

clip_image014

Keep in mind, that while doing using SQLPS.exe within Windows PowerShell, you do have two processes running.

image

So, next time you download your next SQLPS scripts, forget copy/paste into the SQLPS prompt, save the file, and run it from your scripts folder. I guarantee you will have a better user experience with SQLPS.

By the way, have you notice that at the end of the script, we end up with a long directory name.

clip_image018

Well, here’s a short PowerShell script to make it better:

################################################

## 1_chg_Prompt2.ps1

## Author: Max Trinidad, 11/08/2008

################################################

function prompt

{

if ($host.UI.RawUI.CursorPosition.Y -eq 0) { "< $pwd > `n`r" + "PS ["+$host.UI.RawUI.CursorPosition.Y+"] > "}

Else {"PS ["+$host.UI.RawUI.CursorPosition.Y+"] > "}

}

Now, because this is a PowerShell function, we need to running in a different way. We use the dot source method to execute functions in our PowerShell script:

####################################################

# NAME: DotSourcing01.ps1

# AUTHOR: Max Trinidad , PutItTogether

# DATE : 6/24/2009

#

# COMMENT: To help load function: 1_chgprompt2.ps1

####################################################

. .\1_chg_PSprompt2.ps1

cls

clip_image020

Now, change back to your SQL Server folder to get back to your final folder location:

clip_image022

Keep in mind, every time you do a clear screen “CLS”, it will return the folder location on the top of the screen:

clip_image024

Now, you have room to type your script and/or one-liner cmdlets.

clip_image026

Hope you find this information useful so you can enjoy working with both PowerShell and SQLPS.

Here’s some additional resource link on SQPS scripts and SQL Server PowerShell community extensions:

1. Sethu’s Blog: http://blogs.msdn.com/sethus/default.aspx

2. Chad Miller Blog: http://chadwickmiller.spaces.live.com/default.aspx

3. Chad Miller, SQL Server PowerShell Extensions: http://sqlpsx.codeplex.com/

Have fun!!

July 02

Want to know how many PowerShell MVP’s in the world??

We are a total of 35 MVPs in the world.   Check the Microsoft site for more information on how to become an MVP.

:)

 

June 25

Microsoft TechNet, MSDN, and some other learning resources…

Here’s some good Microsoft learning resources and can help you stay up-to-date with new technologies:

image image image image

 

1. Windows 7 Feature Walkthroughs:

http://technet.microsoft.com/en-us/windows/dd320282.aspx

2. TechNet “Microsoft – How Do I? Videos”:

http://technet.microsoft.com/en-us/cc138021.aspx

3. MSDN “Learn” section:

http://msdn.microsoft.com/en-us/bb188199.aspx

4. RAMP UP – Microsoft Developers community based learning program:

http://msdn.microsoft.com/en-us/rampup/default.aspx

5. THRIVE Program:

http://www.microsoft.com/click/thrive/

6. Microsoft Webcast Calendar:

http://www.microsoft.com/events/webcasts/calendar/monthview.aspx

Don’t forget to support your TechNet and MSDN quarterly meetings in your area when available.  And, take advantage of this information that mostly is free to view.

Enjoy!!

June 25th 2009 – So Florida SQL User Group – PowerShell and SQL Server presentation…

Tonight I will be presenting PowerShell and SQL Server bring in some samples.  There will be giveaways you don’t want to miss.  Also, you can download my presentation which includes supporting documents and all the PowerShell script samples.  During this presentation will be covering using SMO and SQLPS to manage your SQL Server. 

Location: DeVry University - SQL Server User Group Meeting, ROOM 254, 2300 SW 145th Ave., Miramar, FL

image

Please click in the following link: ()