SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Paging Doctor Powershell


Paging Doctor Powershell

Author
Message
WI-DBA
WI-DBA
SSC Eights!
SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)

Group: General Forum Members
Points: 876 Visits: 605
Comments posted to this topic are about the item Paging Doctor Powershell

Cheers
http://twitter.com/widba
http://widba.blogspot.com/
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)SSC Guru (99K reputation)

Group: General Forum Members
Points: 99644 Visits: 18616
Nice article and useful tool.

Thanks



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

WI-DBA
WI-DBA
SSC Eights!
SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)

Group: General Forum Members
Points: 876 Visits: 605
Thanks. If folks have ideas on things to add to it, let me know and I can work them in and share the script.

Cheers
http://twitter.com/widba
http://widba.blogspot.com/
dawaller
dawaller
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 347
This looks like some great stuff, however I am new to powershell. Do you have any step by step instructions for running the scripts? I would like to try it out in my test servers.

Thanks,
David
WI-DBA
WI-DBA
SSC Eights!
SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)

Group: General Forum Members
Points: 876 Visits: 605
I don't have anything step by step - but I could easily create a step by step article or a set of blog posts that cover it. Is that something people would like to see? It could be articles or I could just blog it in small bites.

The script I uploaded should be able to be run as long as you have Powershell 2 installed without any issues. (you shouldn't need any experience) Just give it a server name and a few hours and let it run.

Cheers
http://twitter.com/widba
http://widba.blogspot.com/
alen teplitsky
alen teplitsky
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11150 Visits: 4674
nice article, going to have to look at it. right now i have perfmon running on a server dumping data to a central database where i run reports from. this is a lot lighter, but i was going to use the perfmon data for historical baselines as well. one thing i don't like about powershell is that you can't seem to dump the data into SQL
WI-DBA
WI-DBA
SSC Eights!
SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)

Group: General Forum Members
Points: 876 Visits: 605
You can dump directly to SQL, I do that for gathering stats for our VM admins. I don't like looking at csvs or text files anymore than the next DBA.


Once you have a list of counters (note I have some extra properties in my object collection) - you could simply call a proc (or just directly insert them)

$CounterCollection | Where-Object{$_.Path -ne $null} | ForEach-Object{
$qry = "EXEC .dbo.pr_Add_Perf_Collection "
$qry = $qry + " @server='" + [string]$_.Server + "'"
$qry = $qry + ", @performance_metric='" + [string]$_.Path + "'"
$qry = $qry + ", @performance_value=" + [decimal]$_.CookedValue
$qry = $qry + ", @date_sampled='"+ $_.Timestamp + "'"
$qry = $qry + ", @samples_taken=" + $_.Samples
$qry = $qry + ", @sample_interval=" + [int]$_.SampleInterval

Invoke-SqlNonQuery -ServerInstance $SQLServerToStore -Query $qry
}

function Invoke-SqlNonQuery{
param(
[string]$ServerInstance,
[string]$Query
)
$QueryTimeout=30
$conn=new-object System.Data.SqlClient.SQLConnection
$constring = "Server=" + $ServerInstance + ";Integrated Security=True"
$conn.ConnectionString=$constring
$conn.Open()
if($conn){
$cmd=new-object system.Data.SqlClient.SqlCommand($Query,$conn)
$cmd.CommandTimeout=$QueryTimeout
$cmd.ExecuteNonQuery() | out-null
$conn.Close()
}
}

Hope this helps. I will see about writing a perfmon metric gather/storage article if SSC wants to publish it.

Cheers
http://twitter.com/widba
http://widba.blogspot.com/
Aaron Street
Aaron Street
SSC Journeyman
SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)

Group: General Forum Members
Points: 99 Visits: 865
Examples would be helpful how to pipe data directly to sql server database.



WI-DBA
WI-DBA
SSC Eights!
SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)SSC Eights! (876 reputation)

Group: General Forum Members
Points: 876 Visits: 605
This is probably what you are looking for http://gallery.technet.microsoft.com/scriptcenter/2fdeaf8d-b164-411c-9483-99413d6053ae

Note it uses bulkcopy and there are some restrictions with that.

Cheers
http://twitter.com/widba
http://widba.blogspot.com/
Aaron Street
Aaron Street
SSC Journeyman
SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)

Group: General Forum Members
Points: 99 Visits: 865
How could you exclude certain error codes in array string?

The below example does not seem to filter errors from my array.

Ex.

$IgnoreErrorCode=@(
'1608',
'17832',
'17824',
'18456';
)

# Write-Host "Reading SQL Log for $sqlServerName"
try{
$sqlServer.ReadErrorLog() | Where{$_.LogDate -is [datetime] } |
Where-Object{$_.LogDate -gt $DatetoCheck } |
Where-Object{$_.Text -like "*Error*" -or $_.Text -like "*Fail*"} -and ($_.Text -notcontains $IgnoreErrorCode) |
Select-Object LogDate,Text |
Out-GridView -Title "$sqlServerName Log Errors"
} catch {
Write-Host "Error Reading $sqlServer.Name"
}



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search