provides tidbits, ideas and insights to all things Microsoft SQL Server.

Home / Education / Dba’s if you are up late at night ….. again…. check this out!

Dba’s if you are up late at night ….. again…. check this out!


DBA’s take a look at these FREE technology tutorials from the MidnightDBA on youtube

I recently watched this MidnightDBA tutorial on youtube: Beginning Powershell for DBAs This tutorial runs 1 hr and 23 minutes by Sean McCown – SQL Server MVP.

If for no other other reason, listen for some interesting jokes! But be warned, the jokes are much funnier late at night!

According to Sean, “The time has come where DBAs can no longer afford to ignore PowerShell. Not only has it become an integral part of SQL Server, but we’re being asked to do things on a much grander scale than ever before; things that can only be done with PowerShell.’.

Some interesting points Sean discusses in this session

  • PowerShell is a great scripting language.
  • Command prompt commands work in PowerShell.
  • PowerShell scales well but watch out for doing the wrong thing on multiple servers!
  • Many SQL Server tool vendors are adding PowerShell providers.
  • Powershell cmdlets are like stored procs or functions.
  • Get the Microsoft download to install PowerShell: PowerShell Documentation.

Skip to 18 minutes into video for PowerShell commands that are discussed
get-service – lists all services
get-service | where-object{$_.displayname -match “sql”} – lists just SQL services
get-service | ?{$_.displayname -match “sql”} – lists just SQL services using an alias for where-object
cls -clear screen
psdrive – lists providers and root of live objects and everything is considered a drive
cd \sqlserver
cd \sql
cd localhost\default
dir | format-table — lists all info
dir | ft — lists all info alias
dir | format-table Name — only list name column
get-member — you will use this all the time
dir | gm name, schema (alias for get-member) — lists properties
dir | ft name, rowcount, dataspaceused -auto — list tales by rowcount
dir | ?{$_.Schema -eq “person “} | ft name, rowcount, dataspaceused -auto — list tables by rowcount for Schema Person
$a = dir | ?{$_.Schema -eq “person “} | ft name, rowcount, dataspaceused -auto — set variable a to the command
$a – same list as using the entire command
get-help dir – help on dir command
get-service | gm
get-service | x{$_.Stop{} } — will stop all Services on the box —-WATCH OUT !!!!!!!!!!!!!!!!
get-service | ?{$_.Displayname -match “sql” | ?{$ x{$_.Stop{} } — will stop all SQL Services on the box
dir | ft Name
dir | x{$_.Script{}} — generates SQL code for objects
dir | x{$_.Script{} | out-file c:\zztables.txt -a }
dir | ft Processors, ProductLevel -auto
invoke-sqlcmd -database adventureworks -query”select * from person.address” -ft —starts sql command line
$a = invoke-sqlcmd -database adventureworks -query”select * from person.address” -ft —set to a variable
$a = get-content c:\servers.txt — reads the text file
$a — lists everything from the txt file
$a | %{cd sqlserver:sql\$_\default} — connect to server from list of servers
$a = dir
$a | %{…commands go here}

Sorry about any mistypes on the commands! Well worth your time to watch this video to get a jump start on using PowerShell with some basic commands.

As I wrote this… I saw this article in my inbox: PowerShell Core 6.1 Arriving This Month but Compatibility Will Lag. According to the article: ‘Microsoft is deprecating Windows PowerShell in favor of the cross-platform PowerShell Core, which works across various Linux platforms, in addition to Windows. Windows PowerShell development essentially ended with version 5.1 and Windows PowerShell 6.0 ‘.

    This div height required for enabling the sticky sidebar


    Programmer Solutions Inc Websites

    Industrial Supply DealsChicago Job ResourceKansas Job ResourceAlabama Job ResourceAlaska Job Resource
    Office Supply DealsWashington, DC Job ResourceIllinois Job ResourceArkansas Job ResourceArizona Job Resource
    Indiana Job ResourceDelaware Job ResourceCalifornia Job Resource
    Back To School MallDiversity Job ResourceIowa Job ResourceFlorida Job ResourceColorado Job Resource
    First Job ResourceMichigan Job ResourceGeorgia Job ResourceHawaii Job Resource
    Health Care and FitnessFreelance Job ResourceMinnesota Job ResourceKentucky Job ResourceIdaho Job Resource
    Just Best GiftsIntern Job ResourceMissouri Job ResourceLouisiana Job ResourceMontana Job Resource
    Just Clearance SalesSeasonal Job ResourceNebraska Job ResourceMaryland Job ResourceNevada Job Resource
    Just Comparison ShoppingSenior Job ResourceNorth Dakota Job ResourceMississippi Job ResourceNew Mexico Job Resource
    Just OutletsVolunteer Job ResourceOhio Job ResourceNorth Carolina Job ResourceOregon Job Resource
    Luxury Matters
    South Dakota Job ResourceOklahoma Job ResourceUtah Job Resource
    Tradin StuffBlue Collar Job ResourceWisconsin Job ResourceSouth Carolina Job ResourceWashington Job Resource
    Value BuyersExecutive Job Resource
    Tennessee Job ResourceWyoming Job Resource
    Finance Job ResourceConnecticut Job ResourceTexas Job Resource 
    FrontPage HelpHealthcare Job ResourceMaine Job ResourceVirginia Job Resource 
    MCDBA DirectoryIT Job ResourceMassachusetts Job ResourceWest Virginia Job Resource 
    Retired DBAPink Collar Job ResourceNew Hampshire Job Resource  
    SQL Server DirectorySports Job ResourceNew Jersey Job Resource  
    Transact SQL DirectoryWhite Collar Job ResourceNew York Job Resource  
      Pennsylvania Job Resource  
      Rhode Island Job Resource  
      Vermont Job Resource