Sql Server Powershell

Category: Uncategorized


Stop/Disable SqlAgent/MSSQLServer service via Powershell

One-liner to stop and disable the sqlagent and msssqlserver service. Get-Service MSSQLSERVER, SQLSERVERAGENT | Stop-Service -PassThru -Force | Set-Service -StartupType disabled Advertisements

Read More

BCP via Powershell

Quick post on how to use BCP with powershell.  Adjust options to suit your needs. Import-Module SqlPS -DisableNameChecking $query = “SELECT * FROM TABLE” try{ $srcConn = New-Object System.Data.SqlClient.SqlConnection(“PersistSecurityInfo = true;Server=Server1;Database=DBName;Integrated Security=True;Application Name=PowerShell_BCP”); $destConn = New-Object System.Data.SqlClient.SqlConnection(“PersistSecurityInfo = true;Server=Server2;Database=DBName;Integrated Security=True;Application…

Read More

31 Posts of using Sql Server with Powershell: Modules

This isn’t a 31 days series, as I’ll undoubtedly miss a day here and there, so instead, this will just be a ’31 posts’ series instead.  I’m pragmatic.  And lazy. I have noticed there is a bit of discomfort amongst…

Read More

Copy a Sql Server job via Powershell

This function will copy a job from one server to another using powershell. 

Read More

Windows Live Writer

More for me than you.  If you like using windows live writer, the link to download it is now here.

Read More

Get File from AWS S3 via Powershell

Not battle-tested at all.  Use at your own risk.  Works for me though.  You’ll need an $accessKey and $secretKey variables set outside the scope for this to work.  The $bucketName is the bucket that the file is located in.  The…

Read More

mmm…DBA beer

Read More

Code Formatting for Windows Live Writer and WordPress

Just to save you the trouble, here is the best code formatter for windows live writer when publishing to wordpress.  This is more of a reminder for myself so’s I don’t have to scour the web to find this again,…

Read More