Pages

Wednesday, September 21, 2011

SQL Saturday #85

I'll be speaking at SQL Saturday #85 this weekend in Orlando.
Here's another example we'll review during my session "PowerShell by Example".
This example uses the SQLPSX 1.6 function get-sqlserver to return server properties.


This example was inspired by @PaulRandal's Ponderings on the instance-wide fillfactor setting in his SQLskills Insider Tips newsletter of 9/3/2011.  
To become a SQLskills insider, go here.


Looking forward to seeing everyone at SQL Saturday #85!



   1:  # In response to Paul Randal's Ponderings of Sep 3, 2011 regarding fill factor set at the instance level...
   2:  # His Call To Action is to verify it is set to 100. This script provides the basic means to check it on multiple instances.  
   3:  # The results are sent to a csv file
   4:   
   5:  $FilePath = "C:\Output"
   6:  $OutFile = Join-Path -path $FilePath -childPath ("ServerWide_FillFactor" + (get-date).toString('yyyyMMdd_hhmmtt') + ".csv")
   7:   
   8:  # Provide a list of servers one way or another...
   9:  $Servers = 'RED50\SQLEXPRESS'
  10:  #$Servers = get-content 'C:\Input\Servers.txt'
  11:   
  12:  @(
  13:  foreach ($svr in $Servers)
  14:  {
  15:      $s = get-sqlserver $svr
  16:      $s.Configuration | select parent,{$_.Fillfactor.RunValue}
  17:      
  18:  }
  19:  ) | export-csv -noType $OutFile