Marc Davis
asked on
Powershell and multiple SQL Servers and use highest .datpac.
Hi all,
How can I obtain the highest version of a .dacpac to use on a machine given the machine has multiple versions of SQL server installed?
So, we know where is a possibility of:
'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extension s\Microsof t\SQLDB\DA C\130\Micr osoft.SqlS erver.Dac. dll'
'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extension s\Microsof t\SQLDB\DA C\120\Micr osoft.SqlS erver.Dac. dll'
'C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\Microso ft.SqlServ er.Dac.dll '
'C:\Program Files (x86)\Microsoft SQL Server\130\DAC\bin\Microso ft.SqlServ er.Dac.dll '
'C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\Microso ft.SqlServ er.Dac.dll '
'C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microso ft.SqlServ er.Dac.dll '
These could all be on the same machine or let's say even 3 of these (2 is just an example).
We know that any of the 2 first ones would be the highest of all of them so we if out of the first 2 if the machine had them it would take the one with the highest SQLDB\DAC which is the one with the "130" directory.
If it didn't have the first 2 but the others it would take the one with the "Microsoft SQ Server" with the "140" but if the machine didn't have the "140" SQL Server it would look at the one with the "130" directory, etc.
How can I do a Powershell script that will iterate through all those directories (and may not be in that order) and give me the directory with the highest DAC pack numbered directory?
Please let me know on that.
How can I obtain the highest version of a .dacpac to use on a machine given the machine has multiple versions of SQL server installed?
So, we know where is a possibility of:
'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extension
'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extension
'C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\Microso
'C:\Program Files (x86)\Microsoft SQL Server\130\DAC\bin\Microso
'C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\Microso
'C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microso
These could all be on the same machine or let's say even 3 of these (2 is just an example).
We know that any of the 2 first ones would be the highest of all of them so we if out of the first 2 if the machine had them it would take the one with the highest SQLDB\DAC which is the one with the "130" directory.
If it didn't have the first 2 but the others it would take the one with the "Microsoft SQ Server" with the "140" but if the machine didn't have the "140" SQL Server it would look at the one with the "130" directory, etc.
How can I do a Powershell script that will iterate through all those directories (and may not be in that order) and give me the directory with the highest DAC pack numbered directory?
Please let me know on that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
But outside of that it works great and thanks!