#sqlsat89: No Excuses. Be Involved.

When I first submitted my sessions to SQL Saturday #89 in Atlanta, I had no idea that so many fantastic speakers would be there.  If I had known, I probably would not have gotten involved.  You shouldn’t be like me.

From my point of view, it was an injustice to the attendees for me to take a speaking slot from any one of the amazing experts in attendance.  Would those who attended my session have learned more about PowerShell from Nic Cain (T | B), Jim Christopher (T | B) or Aaron Nelson (T | B)?  Yep.  Is there someone who was overlooked who would have had a better session than mine?  Certainly.  It would have been a stronger event if someone else had taken my place, but it may not have been a stronger community.

What I understand now is that there isn’t much to a community where only the top experts contribute.  We need them.  I need them.  But, a community is composed of people who are involved.  I have some knowledge of and a lot of passion for PowerShell and SQL Server and I wanted to give as much of that as I could to the people who were in my session.  And that’s what PASS is all about: giving whatever you can, even if others can give more.

Speaking at #sqlsat89 is one of the best experiences I’ve ever had in my career.  My session went very well and some new opportunities opened for me. I learned about parallelism from Adam Machanic (T | B) and about waits and latches from Bob Ward (T | B) .  Most importantly, I met many fantastic people I hope to see many more times at future events.  I will speak again and I will continue getting better. I will learn more and contribute more.  And one day I will be one of the experts getting bumped for a first time speaker.  I hope that will be someone who reads this and decides to become part of this fantastic SQL Server community.

#sqlsat89 scripts

Here are the scripts I used during my session, Getting Started With PowerShell. I’ll have an after event post soon.

Starting Services:


#Start SQL Server
Get-Command
Get-Command -CommandType Cmdlet
Get-Command -CommandType Cmdlet | Format-Table name

# List all services
Get-Service 

# Attempt to filter on the "SQL" string
Get-Service | Select-String -Pattern "SQL"

# The filter doesn't work, why not?
Get-Help Select-String

# The output of Get-Services is an array of objects!
Get-Service | Get-Member ;

# Use the Where-Object cmdlet to filter the results
Get-Service | Where-Object{$_.Name -match "SQL"}

# You can start every service on the server at once if you want. 
# Get-Service | Where-Object{$_.Name -match "SQL"} | Start-Service

# Use the -Force parameter to ignore dependencies
# Get-Service | Where-Object{$_.Name -match "SQL"} | Stop-Service -Force

# There are several ways to start the services
# Start-Service "SQLSERVERAGENT" ;
# Start-Service "MSSQLSERVER" ;

Start-Service "MSSQLSERVER", "SQLSERVERAGENT" ; 
"MSSQLSERVER", "SQLSERVERAGENT" | Start-Service;

Renaming Agent Jobs:


# Declare a variable for the desired username
$job_owner = "DBAsRule" ;

# Even text is an object!
$job_owner |Get-Member

# Declare the intention to use the Microsoft.SqlServer.SMO .NET namespace
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | Out-Null

# The PowerShell 2.0 convention is to use Add-Type, but it is sometimes problematic.
# Add-Type -AssemblyName "Microsoft.SqlServer.SMO"
# Add-Type -path “C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Smo\11.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Smo.dll”

# Store an instance of the local SQL in a variable
$sql_server_object = New-Object Microsoft.SqlServer.Management.SMO.Server('localhost')

# Get-Help Get-Member

# Get the SQL Agent SMO object
$sql_server_agent = $sql_server_object.JobServer;

# $sql_server_agent | Get-Member

# Get the JobCollection object
$jobs = $sql_server_agent.Jobs;



foreach($j in $jobs)
{
	$j.OwnerLoginName;
}


foreach($j in $jobs)
{
	if($j.OwnerLoginName -ne $job_owner )
	{
		$j.OwnerLoginName = $job_owner;
	}	
}