Press "Enter" to skip to content

Category: Powershell

Deploying Dacpacs

Richie Lee shows two different methods of automating Dacpac deployment:

DacFx, or to give it it’s full title, the Data-tier Application Framework “is a component which provides application lifecycle services for database development and management for Microsoft SQL Server and Microsoft Azure SQL Databases“. Essentially, it is another method we can use to manage our Dacpacs. However instead of using the external process SQLPackage and initiating it via cmdline you can use C# or PowerShell to manage Dacpacs. In fact, SQLPackage uses the “Microsoft.SqlServer.Dac.dll” itself. You can verify this by going and deleting the dll and trying to run sqlpackage via command line…. or you can just take my word for it.

Read on for the Powershell script Richie uses.

Comments closed

Scripting SQL Server Objects With Powershell

Sander Stad provides a script to export SQL Server objects using Powershell:

Scripting SQL Server objects manually through the SQL Server Management Studio can be a tedious task. Last week I published a script to export database objects with PowerShell. I wanted to take this a little further and create a solution to export SQL Server objects as well.

Because this would be a nice addition to the PSSQLLibmodule, this function is also included in the library from today.

I haven’t tried using this cmdlet yet, but it does look handy.

Comments closed

Powershell + Bash

Max Trinidad shows how to integrate Powershell with Bash in Windows 10:

If it worth knowing that in order to get Bash, it’s a feature you need to installed it first. The following is the series of steps I use to enabled and install Bash on my desktop. And, after enabling Bash, I started using it under the PowerShell Console.

Apropos of this, I read a very interesting article by Alex Clemmer yesterday on how terrible the Windows command line is.  Powershell and Bash are way, way better for pretty much any purpose, other than perhaps experiencing masochism.

Comments closed

Powershell Remoting

Andrew Pruski demonstrates Powershell remoting:

Hey guys, differing from usual this is a quick post on setting up powershell remote sessions. I know you can remotely connect to powershell sessions using the Server Manager that comes with Windows Remote Administration Tools but it’s a bit of a clicky process and I like to eliminate using the mouse as much as possible.

Disclaimer! I’m not a scripter, there are probably much better ways of doing this but I’ll show you the way I set it up and how to fix any errors you may come across.

If you’re using Remote Desktop to connect to servers, especially for regular actions, you should definitely check out Powershell remoting.

Comments closed

New Powershell Cmdlets Proposed

Aaron Nelson has proposed breaking up SQLPackage.exe into at least three cmdlets:

SQLPackage.exe – Needs to be made into at least 3 cmdlets

SQLPackage.exe – Needs to be made into at least 3 cmdlets (and possibly more; we have added ideas for additional cmdlets below). The first 3 cmdlets that need to be made into are:

  • Export-SqlDatabase

  • Import-SqlDatabase

  • Compare-SqlDatabase

This seems reasonable and would help maintain databases.

Comments closed

SQLPS Fixed

Chrissy LeMaire and Aaron Nelson have succeeded; Microsoft has fixed the three issues with SQLPS:

In my previous blog post “Can We Get These 3 SQLPS Issues Fixed before SQL Server 2016 RTMs?“, Aaron Nelson and I asked the SQL and PowerShell community to help upvote 3 SQL Connect items. The items addressed three problems with SQL Server’s PowerShell module, SQLPS.

  • It took 3-5 seconds to load
  • It changed the present working directory when loaded
  • It produced approved verb warnings when loaded

Today, Microsoft responded, letting everyone know that the issues were addressed in SQL Server Management Studio March 2016 Refresh.

Given the reputation Connect has in the community, I’m glad to see these issues get fixed.

Comments closed

SQL Server 2016 PS Manifest

Drew Furgiuele digs into why Powershell scripts break with SQL Server 2016:

One of the steps I tried to remedy the problem was removing the SQLPS module directory from the PSModulePath environment variable, to see if the Import-Module would skip over it. Turns out I was only half right: I should have removed non 2016 versions of the module path, as Matteo goes on to explain:

I’m hoping there will be a real fix for RTM.  This works, but it’s neither intuitive nor easily decipherable.

Comments closed

Autostart XE With Powershell

Rob Sewell shows us how to set a particular extended event to start automatically when SQL Server starts up:

Very quick and simple and hopefully of use to people, this could easily be turned into a function. The full script is below and also available here on the Powershell gallery or by running  Save-Script -Name Set-ExtendedEventsSessionstoAutoStart -Path <path>

This is indeed a quick and easy script, and quite useful when checking across a large number of instances.

Comments closed

Power BI Auto-Installation

Simon Sabin uses Powershell to install Power BI:

Having recently been having rebuilding my machine I finally decided to automate the process of installing the software I need.

This was a life saver as I was reinstalling a few times to try and figure out why I wasn’t getting sound on my external monitor. So I was gradually uninstalling everything until I found out that it was Hyper-v that was causing the problem.

The outcome meant I was installing PowerBI lots and had to automate it.

This looks like the first step toward a Chocolatey script.

Comments closed