Southwest Florida .NET CodeCamp 2010 – Call for Speakers…

Calling all speakers to submit their presentation(s) and make this event a success.  It doesn’t matter if its PowerShell or SQL Scripting, come on that show your code.  Let’s share our knowledge and be proud of it!!

Here’s the official site: http://codecamp.swfldev.net/

If you have some interesting code…  come and show us.

Register now!!

Posted in Uncategorized | Leave a comment

Microsoft Firestarter Event coming your way!!!

Microsoft TechNet is turning up the heat with these two firestarter event coming to a city near you.

SharePoint 2010 Fire Starter: – https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032457063&Culture=en-US

Windows 7 Deployment Fire Starter: – https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032456971&Culture=en-US

Go on and Register today before is too late!

Posted in Uncategorized | Leave a comment

Big Surprise!! We got both the Scripting Guy and Wife coming to SQLSaturday #49…

Yes, I just got confirmation from Ed Wilson that both he and wife have registered to the Orlando SQLSaturday #49 on October 16th.  This event is full of Awesome SQL Server topics and will include some PowerShell sessions.

Come, join us and say Hi!.

Posted in Uncategorized | Leave a comment

It’s Official next Florida PowerShell User Group Meeting – Monday, August 16th 6:30PM…

Yes, Everyone is welcome to our next PowerShell meeting – “Topic:  Working with Functions”

Topic:  Working with Functions…

Location:

New Horizons of South Florida
Ft. Lauderdale Office
100 S. Pine Island Rd
Plantation, FL 33324

954-572-8600
or register on our website:
http://www.flpsug.com/
Meeting starts at 6:30PM

Posted in Uncategorized | Leave a comment

#SQLSat 40 – First SQL PowerShell track winners…

#SQLSat40 – I just emails 7 winners who attended our first #SQL Server #PowerShell Track-2 PSP editor, 2 PrimalScript2K9 & 3 PrimalSQL 2K9 were given away.

Congratulation to the winners:

Jeff Cuscutis PrimalSQL 2009
Bill Ehrreich PrimalSQL 2010
Craig Bourque PrimalSQL 2011
Justin Sheldon PrimalScript 2009
Kendra Little PrimalScript 2010
Shajay Das Idera PowerShell Plus
Diosmar Perez Idera PowerShell Plus

Please check your emails!

Thanks for attending SQLSatuday South Florida Event on July 31st 2010.

Max Trinidad

Posted in Uncategorized | Leave a comment

SQLSaturday 40 So.Florida–The first SQL PowerShell Track was a Successful event.

clip_image002

Thanks to the SQLSaturday organizers to allow us create the first official SQL PowerShell Track.  All sessions were full of people and all speakers gave excellent material.  Also, without the participation of all attendees, you all made it possible.

This was a great event. Here’s some pictures:

clip_image004

Ron Dameron, full house.

clip_image006

SAPIEN’s David Corrales, Visual PowerShell 2011.

clip_image008

Aaron Nelson with Andy Warren.

clip_image010

Myself (Max Trinidad)

clip_image012

Speaker Dinner at Pembroke Pines “Longhorn Restaurant”.

clip_image014

SQLSaturday closing event.

Also, special “Thanks!!”, both SQLSaturday and PowerShell sponsors who provided some excellent giveaways during our sessions: SAPIEN, QUEST/PowerGui, and IDERA.

SAPIEN BUTTON LOGO 2.5 inch with TEXT®

clip_image016

clip_image017

Come and see us again on Saturday, October 16th in Orlando SQLSaturday #49.

Posted in Uncategorized | Leave a comment

Ready, Set, Go SQLSaturday !!! Come to see us…

Yes! The stage is set, and we are ready to give some Awesome presentations.  Please, don’t be a stranger!! Come to both upcoming SQLSaturday events: South Florida (SQLSat40) and Orlando (SQLSat49).   We finally organized a full day of PowerShell.  It’s going to be fun and very informative.

Please, click on the following link for both the registration and to see the full event schedule with all other great tracks at:

On July 31st, South Florida SQLSaturday #40: http://www.sqlsaturday.com/40/schedule.aspx

On October 16th, Orlando SQLSaturday #49: http://www.sqlsaturday.com/49/schedule.aspx

Here’s the PowerShell Tracks for both events:

Start Time SoFla – SQLSaturday #40 – PowerShell Track
8:30 AM Ronald Dameron
  Why SQL Server DBAs should learn PowerShell
9:45 AM Ronald Dameron
  Automate ID Administration w/ PowerShell & SQLPSX
11:00 AM Aaron Nelson
  PowerShell for the Data Professional
1:00 PM David Corrales
  Sneak Preview: SAPIEN’s Visual PowerShell 2011
2:15 PM Maximo Trinidad
  Working with SQL Server – SQLPS
3:30 PM Maximo Trinidad
  Using PowerShell with SQL Server Agent
8:30am Argenis Fernandez
  Multi-Server Management with SQL Server 2008+
Start Time Orlando -SQLSaturday #49 – Powershell Track
9:00 AM Maximo Trinidad
  Working with SQL Server – SQLPS
10:15 AM Aaron Nelson
  The Dirty Dozen: PowerShell Scripts for Busy DBAs
11:30 AM Maximo Trinidad
  Using PowerShell with SQL Server Agent
1:15 PM Ron Dameron
  Why a DBA Should Learn PowerShell (MINI)
1:30 PM Ronald Dameron
  Automate Login Administration & Compliance Reports
2:45 PM Aaron Nelson
  PowerShell 2.0 Beyond the Dirty Dozen
4:00 PM Chad Miller
  ETL with PowerShell

Remember, Registration is free!!

Posted in Uncategorized | Leave a comment

Invoke-SQLCmd minor issue running some SQL Stored-Procedures…

First time I notice something strange with “Invoke-SQLCmd”, I was when executing the system Stored-Procedure “SP_Who2” and got the following error message:

PS C:\Users\Max> $sqlWho = Invoke-Sqlcmd “SP_Who2″
Invoke-Sqlcmd : The pipeline has been stopped.
At line:1 char:24
+ $sqlWho = Invoke-Sqlcmd <<<<  “SP_Who2″
    + CategoryInfo          : InvalidOperation: (:) [Invoke-Sqlcmd], PipelineStoppedException
    + FullyQualifiedErrorId : SqlExectionError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

Invoke-Sqlcmd : A column named ‘SPID’ already belongs to this DataTable.
At line:1 char:24
+ $sqlWho = Invoke-Sqlcmd <<<<  “SP_Who2″
    + CategoryInfo          : InvalidOperation: (:) [Invoke-Sqlcmd], DuplicateNameException
    + FullyQualifiedErrorId : SqlServerError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

PS C:\Users\Max>

I was trying to create a collection of object with the results from my “SP_Who2” and got the error stating “.. A column named ‘SPID’ already belongs to this DataTable..”.   So, I end up scripting out the SP_Who2, finding there are two columns with the same name ‘SPID’ and PowerShell didn’t like it.  I made the change to rename one of the columns to be SPID2 and save the T-SQL script to my PowerShell script file. 

And, the next time the ran my “Invoke-SQLCmd”, I had no problems and got my results so I could manipulate my .NET objects.

So, this is to make you aware that you will experience this minor issues when executing some of the SQL system stored-procedures.  And, for those who wonder… is this a BUG??  I really don’t think so!!  Because, the issue is in some of the system stored-procedures.  Should I submit this issue to the SQL Team to fix all stored-procedures generating columns with the same name?  This could be a major and unnecessary task.  Anyway, you were served!!

Happy PowerShelling!!

Posted in PowerShell, SQL Server | Tagged , | Leave a comment

QuickBlog: Build a list of SQL Server without SMO…

Here I’m sharing a piece of PowerShell  code snippet which allow you to create a string array of all your SQL Server with their instances.  This code is a .NET namespace and use the enumerator class “SqlDataSourceEnumerator” to give you all available SQL Server instances in your network.

Just go ahead and give it a try:

$SQLInst = [System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() `
| select @{Expression={if(($_.InstanceName).length -gt 0)`
{$_.ServerName+"\"+$_.InstanceName}else{$_.ServerName}}; Name="SQLName"}
[Array] $MyServers
$MyServers = foreach($i in $SQLInst) {$i.SQLname}

Please, notice I’m using the reverse accent character for line continuation so it’s easy to view.  This is a good code snippet, if you need to provide a script solution that may required to get some SQL information from scheduled task on a server that have no SQL engine installed.

Hint: Now, you may have another way to void typing all your server in your PowerShell script.

Also, take a look at this other blog from Thomas LaRock “SQL RockStar” about “Finding Servers on Your Network” – Excellent material – http://thomaslarock.com/2009/12/finding-servers-on-your-network/  (Thanks to Chad Miller! For providing the link)

Here’s another snippet using above Thomas LaRock blog but I use PowerShell to extend the command “sqlcmd /L”:

$s = sqlcmd /L
[array] $Servers = $null
[array] $Servers = foreach($i in $s){if($i.length -gt 0){$i.Trim()}}
$Servers

Happy PowerShelling!!!

:)

Technorati Tags: ,
Posted in PowerShell, SQL Server | Leave a comment

PowerShell Modules – How to create Aliases for my functions?

There’s tons of information about PowerShell Modules on the internet.  Then I realized, in my PowerShell Modules, How do I create Aliases for my functions?  I couldn’t find any information on the internet about Aliases in modules.  So, thanks to Ed Wilson (Microsoft Script Center), he gave me a hint in one of his articles: http://blogs.technet.com/b/heyscriptingguy/archive/2010/02/21/hey-scripting-guy-february-21-2010.aspx

I’m assuming you already know how to create a module *psm1 file. Well, don’t worry!  The following sample script will get you started.  And, if you want to convert a PowerShell script to a Module file, is as simple as copy the *ps1 to *psm1 file.  Basically, that’s it!!

So, before I created my module file, I first created a PowerShell script “HelloWorld.ps1″ which contains the following code:

## NAME: HelloWorld.ps1
Function Show-HelloWorld {
 [CmdletBinding()]
   Param($arg)
           Write-Host "Hello World!!.." $arg
};Set-Alias shw Show-HelloWorld -Description "Sample Hello World in module"

After verifying that my function works, then I copy/rename my PowerShell script to PowerShell module file “HelloWorld.psm1″ and saved it in my new module folder name “HelloWorld”.

Now, here’s what I found when creating my Aliases for my module:

  1. In the *psm1 file, I could use either: Set-Alias or New-Alias but not both when buidling my manifest.  One catch, I discovered, if I use the ‘-Description’ parameter in either Cmdlets, the function description won’t load with the module.  (its a possible bug)
  2. The last line in the *psm1 file need to have the Cmdlet “Export-ModuleMember” (a shown below) to include the Aliases.
  3. I think is a good practice to named you PS Module script the same way your Module folder.
  4. Create the Module folder name and place the module *psm1 file in it.

Here’s sample script code:

## PS Module Name: HelloWorld.psm1
Function Show-HelloWorld {
 [CmdletBinding()]
   Param($arg)    �
   Write-Host "Hello World!!.." $arg
};
#-- Set-Alias will work but can't be New-Alias
#Set-Alias shw Show-HelloWorld -Description "Sample Hello World in module"
New-Alias -Name shw -value Show-HelloWorld -Description "Sample Hello World in module"
 
#-- Need to be included at the end of your *psm1 file.
export-modulemember -alias * -function *

Now, we need to create our new module folder under our users documents “..\WindowsPowerShell\Modules” called “HelloWorld”.   Using our PowerShell console, we need to create our PowerShell manifest *psd1 file using the following line and pressing enter to all other prompts:

New-ModuleManifest -Path 'C:\Users\YourName\Documents\WindowsPowerShell\Modules\HelloWorld\HelloWorld.psd1' -ModuleToProcess 'C:\Users\YourName\Documents\WindowsPowerShell\Modules\HelloWorld\HelloWorld.psm1'
PS C:\Users\Max&gt; New-ModuleManifest -Path 'C:\Users\max\Documents\Win...
' -ModuleToProcess 'C:\Users\max\Documents\WindowsPowerShell\Modules\...
 
cmdlet New-ModuleManifest at command pipeline position 1
Supply values for the following parameters:
NestedModules[0]:
Author:
CompanyName:
Copyright:
Description:
TypesToProcess[0]:
FormatsToProcess[0]:
RequiredAssemblies[0]:
FileList[0]:

Keep in mind, to start using New-ModuleManifest, you only need to use two parameters: “-path” – location to store your manifest file and “-ModuleToProcess” – location of your module file.

Don’t be afraid to skip the prompts, you can always go back into your recently build manifest file *psd1 and manually filled the information.  After successfully running the “New-ModuleManifest” and created the manifest file “HelloWorld.psd1″, I can proceed to load our new module using “Import-Module HelloWorld”.  If there were any errors, I would need to go back to file my *psm1 module file.

I’m are ready to test the new “HelloWorld” module executing the “Import-Module HelloWorld” im the PowerShell Console:

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\Max> New-ModuleManifest -Path 'C:\Users\max\Documents\WindowsPowerShell\Modules\HelloWorld\HelloWorld.psd1'
-ModuleToProcess 'C:\Users\max\Documents\WindowsPowerShell\Modules\HelloWorld\HelloWorld.psm1'

cmdlet New-ModuleManifest at command pipeline position 1
Supply values for the following parameters:
NestedModules[0]:
Author:
CompanyName:
Copyright:
Description:
TypesToProcess[0]:
FormatsToProcess[0]:
RequiredAssemblies[0]:
FileList[0]:
PS C:\Users\Max>
PS C:\Users\Max> Import-Module HelloWorld
PS C:\Users\Max> Get-Alias Shw

CommandType     Name                                                Definition
-----------     ----                                                ----------
Alias           shw                                                 Show-HelloWorld

PS C:\Users\Max> shw
Hello World!!..
PS C:\Users\Max> shw Max
Hello World!!.. Max
PS C:\Users\Max>

Now, I can either use my new Cmdlet function “Show-HelloWorld” or just use the Alias “shw” to execute my function.  That’s it!!  I’ve just created, loaded and tested a new module in our PowerShell Console.  There’s room to grow here!! 

Remember, Don’t TAP OUT!!  Happy PowerShelling!!

Posted in PowerShell | Tagged | Leave a comment