<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technology StarLog</title>
	<atom:link href="http://bitwisemnm.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bitwisemnm.com</link>
	<description>chronicling journeys through the technology Universe by BitWise MnM</description>
	<lastBuildDate>Mon, 20 Feb 2012 09:09:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SQL server powershell war chest &#8211; advanced connection provider</title>
		<link>http://bitwisemnm.com/2012/02/sql-server-powershell-war-chest-advanced-connection-provider/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sql-server-powershell-war-chest-advanced-connection-provider</link>
		<comments>http://bitwisemnm.com/2012/02/sql-server-powershell-war-chest-advanced-connection-provider/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 08:26:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://bitwisemnm.com/?p=109</guid>
		<description><![CDATA[in a previous post I covered a basic connection provider, which is nice, but has its limitations. biggest one being that you always have to supply credentials. If you&#8217;re like most DBAs, chances are that you usually work on several &#8230; <a href="http://bitwisemnm.com/2012/02/sql-server-powershell-war-chest-advanced-connection-provider/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>in a previous <a href="http://bitwisemnm.com/2011/12/sql-server-powershell-war-chest-connection-provider/">post</a> I covered a basic connection provider, which is nice, but has its limitations. biggest one being that you always have to supply credentials. If you&#8217;re like most DBAs, chances are that you usually work on several servers in different environments and entering the login info all the time can get tedious. Of course integrated authentication helps a bit, but still, for those that still use SQL logins it could be a bit of a nuisance. All of this was a problem until my friend Jorge Satorre showed me a beautiful solution that I will share with you here. <br />
First of all, let&#8217;s start from the basics &#8211; saving your password for future reuse. This <a href="http://blogs.technet.com/b/robcost/archive/2008/05/01/powershell-tip-storing-and-using-password-credentials.aspx">blog post</a> may come in handly. Jorge likes Powershell Cookbook (I believe it&#8217;s <a href="http://www.amazon.com/Windows-PowerShell-Cookbook-Scripting-Microsofts/dp/0596801505/ref=sr_1_1?ie=UTF8&amp;qid=1329725230&amp;sr=8-1">this one</a>). In any case, first step is to save a password to a file. It&#8217;s a bit of a tango twist, but not too confusing. First we create an object with the following properties &#8211; AuthenticationType, Username and SecurePassword. AuthenticationType can be integrated or regular: </p>
<pre class="brush: powershell; title: ; notranslate">
$object = &quot;&quot; | Select-Object AuthenticationType,Username,SecurePassword
</pre>
<p>
the twist happens when saving a password. We take it from a regular string to a secure string: </p>
<pre class="brush: powershell; title: ; notranslate">
convertto-securestring &quot;P@ssW0rD!&quot; -asplaintext -force
</pre>
<p>then we encrypt the secure string for storage and export to an xml file: </p>
<pre class="brush: powershell; title: ; notranslate">
$object = &quot;&quot; | Select-Object AuthenticationType,Username,SecurePassword
$object.AuthenticationType = &quot;regular&quot;
$object.Username = &quot;superuser&quot;
$object.Password = convertto-securestring &quot;P@ssW0rD!&quot; -asplaintext -force | ConvertFrom-SecureString
$object |  Export-Clixml ./ServerA.xml
</pre>
<p>we can create a file for each server and store them in a save location. As you will see in the connection script I store my server authentication files in c:\powershell\ss. <br />
We&#8217;re almost done. Now our get_connection script just needs two params &#8211; a database name and a server. </p>
<pre class="brush: powershell; title: ; notranslate">
param(
	  [string] $database = &quot;MYdb&quot;,
	  [string] $dataSource=&quot;ServerA&quot;
     )
</pre>
<p>all we have to do is to read the credential file and construct a connection string accordingly. If the AuthenticationType is &#8220;regular&#8221; we will also read the username/password pair.</p>
<pre class="brush: powershell; title: ; notranslate">
       $Path = &quot;c:\powershell\ss\$dataSource.XML&quot;

        # Import credential file
        $import = Import-Clixml $Path 

if ($import.AuthenticationType -eq &quot;Integrated&quot;)

{
$authentication = &quot;Integrated Security=SSPI;&quot;
}
else
{
        # Test for valid import
        if ( !$import.UserName -or !$import.Password ) {
                Throw &quot;Input is not a valid ExportedPSCredential object, exiting.&quot;
        }

		$username = $import.Username

		        # Decrypt the password and store as a SecureString object for safekeeping
        $SecurePass = $import.Password | ConvertTo-SecureString

        # Build the new credential object
        $Credential = New-Object System.Management.Automation.PSCredential $Username, $SecurePass

	    $plainCred = $credential.GetNetworkCredential()
    	$authentication = (&quot;uid={0};pwd={1};&quot; -f $plainCred.Username,$plainCred.Password)
}

$connectionString = &quot;Persist Security Info=True;Initial Catalog=$database;Data Source=$dataSource;$authentication&quot;
</pre>
<p>that&#8217;s it. Now all of your servers are at your fingertips. Download the <a href="http://bitwisemnm.com/blog/Downloads/Get_connection.advanced.ps1">get_connection script</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bitwisemnm.com/2012/02/sql-server-powershell-war-chest-advanced-connection-provider/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically deploying data dude projects with vsdbcmd.exe</title>
		<link>http://bitwisemnm.com/2012/01/automatically-deploying-data-dude-projects-with-vsdbcmd-exe/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automatically-deploying-data-dude-projects-with-vsdbcmd-exe</link>
		<comments>http://bitwisemnm.com/2012/01/automatically-deploying-data-dude-projects-with-vsdbcmd-exe/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 10:21:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL server]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://bitwisemnm.com/?p=51</guid>
		<description><![CDATA[In a previous post, I talked about automatically building a database project outside of Visual Studio. Just for the sake of a feeling of completeness, I will also add a script for deploying the said project to a database of &#8230; <a href="http://bitwisemnm.com/2012/01/automatically-deploying-data-dude-projects-with-vsdbcmd-exe/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In a previous post, I talked about automatically building a database project outside of Visual Studio. Just for the sake of a feeling of completeness, I will also add a script for deploying the said project to a database of your choice.</p>
<p>There are many ways to deploy a database project. See for example <a href="http://msdn.microsoft.com/en-us/library/dd193258.aspx">this msdn reference</a> for examples of deploying without having to specify a connection string on a command line, or <a href="http://www.justaprogrammer.net/2011/10/27/continuous-integration-with-tfs2010-msdeploy-vsdbcmd/">Justin&#8217;s blog </a>on using TFS build templates, or <a href="http://sqlblog.com/blogs/jamie_thomson/default.aspx">jamie thomson </a>on using msbuild scripts.&nbsp; For my part, I’m driven by a desire to accomplish as much as possible with doing as little as possible. So, after I run the build script and all is well, I want to re-use the build output files without modifying them at all.</p>
<p>Build the output directory should contain the following files:</p>
<ul>
<li>dbname.dbschema
<li>dbname.deploymanifest
<li>dbname.sqlcmdvars
<li>dbname.sqldeployment
<li>dbname.sqlsettings
<li>dbname.PostDeployment.sql
<li>dbname.PreDeployment.sql </li>
</ul>
<p>they should contain all the info that we need to run vsdbcmd.exe. we’ll just need to add few params:</p>
<ul>
<li>connections string
<li>manifest location
<li>target db name </li>
</ul>
<p>that’s all really. We’ll need to add some basic params just so that vsdbcmd.exe knows what we want from it, such as:</p>
<ul>
<li>action (deploy)
<li>deploy to database
<li>verbose/silent mode </li>
</ul>
<p>As you may have guessed, I’m going to use powershell to run it:
<pre class="brush: powershell; title: ; notranslate"> $connStr=&quot;Persist Security Info=True;Initial Catalog=&quot;&quot;dbname&quot;&quot;;Data Source=127.0.0.1;uid=&quot;&quot;user&quot;&quot;;pwd=&quot;&quot;password&quot;&quot;;&quot;
$pr1=&quot;/Action:Deploy&quot;;
$pr2=&quot;/dd:+&quot;;
$pr3=&quot;/cs:&quot;+$connStr
$pr4=&quot;/manifest:&quot;&quot;&quot;+$buildOutput+&quot;\&quot;+$dbname+&quot;\&quot;+$dbname+&quot;.deploymanifest&quot;&quot; &quot;
$pr5=&quot;/p:TargetDatabase=&quot;&quot;&quot;+$dbname+&quot;&quot;&quot; &quot;
$pr6=&quot;/q:+&quot;  </pre>
</p>
<p>Check out <a href="http://msdn.microsoft.com/en-us/library/dd193283.aspx">this msdn page </a> for more info on individual parameters. $buildOutput&nbsp; is the path to the build output files. If I want to deploy a bunch of databased, I could turn $buildOutput&nbsp; and $dbname into parameters and loop through the project directories. But&nbsp; I don’t find myself deploying many databases at once. If an environment really needs to be refreshed, it’s better to do it from a CI tool, so that there is a record of action and so on.</p>
<p>You may have noticed that I put each param into a separate variable. This is because of a strange quirk of Powershell &#8211; vsdbcmd.exe combination. You can’t just create one long string with parameters and execute vsdbcmd with it. Vsdbcmd will think that the entire string is an /Action command. From a cmd batch file it works fine.</p>
<p>In any case, all’s left is to specify a path to vsdbcmd and execute it</p>
<pre class="brush: powershell; title: ; notranslate">
$ex=&quot;C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy\vsdbcmd.exe&quot;
#execute the deploy command
&amp; $ex $pr1 $pr2 $pr3 $pr4 $pr5 $pr6;
</pre>
<p>That’s it really. As simple as it gets. If something went wrong vsdbcmd will complain about it. If you want to be a bit more proactive about it, you can follow <a href="http://blogs.msdn.com/b/gertd/archive/2009/07/21/vsdbcmd-exe-return-codes.aspx">Gert D’s </a>&nbsp; suggestion with a Powershell twist:</p>
<pre class="brush: powershell; title: ; notranslate">
#check if succeeded or not
if ($?) {Write-Host &quot;database &quot;,$dbname,&quot; successfully deployed&quot;}
	else {Write-Host &quot;deployment for &quot;,$dbname,&quot; failed&quot;}
</pre>
<p>Download a <a title="DBA script to deploy a DB project" href="http://bitwisemnm.com/blog/Downloads/vsdbcmd deploy.ps1">sample powershell script</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bitwisemnm.com/2012/01/automatically-deploying-data-dude-projects-with-vsdbcmd-exe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>building your database solutions outside of Visual Studio</title>
		<link>http://bitwisemnm.com/2012/01/building-your-database-solutions-outside-of-visual-studio/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-your-database-solutions-outside-of-visual-studio</link>
		<comments>http://bitwisemnm.com/2012/01/building-your-database-solutions-outside-of-visual-studio/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 08:52:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[IDE]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[SQL server]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[mslbuild]]></category>

		<guid isPermaLink="false">http://bitwisemnm.com/?p=43</guid>
		<description><![CDATA[Visual Studio database solutions provide DBAs with a lot of functionality not the least of which is ability to spot errors before scripts are deployed. One thing to be aware, though that there are three levels of error catching - &#8230; <a href="http://bitwisemnm.com/2012/01/building-your-database-solutions-outside-of-visual-studio/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Visual Studio database solutions provide DBAs with a lot of functionality not the least of which is ability to spot errors before scripts are deployed. One thing to be aware, though that there are three levels of error catching -</p>
<ul #access>
<li>as soon as a file is saved, VS checks syntax and references</li>
<li>at build time references are re-examined and more thorough checking is conducted</li>
<li>during a deployment execution related errors are surfaced</li>
</ul>
<p>the first two steps roughly correspond to what happens when a create object script is executed in the Management Studio.</p>
<p>So logical thing to do, of course, would be to re-build you DB solution as you&#8217;re making changes. if you have Continuous integration that runs the build process for you that could be one option, but normally it takes time until the build server processes your solution. Especially given that DB solutions tend to take longer than let&#8217;s say C# projects. You can of course re-build right in your VS studio, but that means a lot of thumb twiddling or lots of coffee runs.</p>
<p>One simple answer is to use msbuild.exe to re-build your DB &#8220;from outside&#8221;. I&#8217;ve been using a poweshell script to do this (surprise) with a lot of success. It gives me instant visual ques and provides a log file that I can use for further troubleshooting if needed. and also I can use the output for deploying the database to an actual SQL server using vsdbcmd.exe. After having read a great blog post on this subject by <a title="SSIS Junkie" href="http://sqlblog.com/blogs/jamie_thomson/default.aspx">jamie thomson aka SSIS Junkie</a> I felt compelled to share my build script. Here it is:</p>
<pre class="brush: powershell; title: ; notranslate">
#MSBUILD.PS1
# automate build

[string]$output=&quot;&quot;

$logpath=&quot;c:\PowerShell\log\buildLog.txt&quot;

if (Test-Path $logpath)
{Remove-Item $logpath}

#output path
$buildOutput=&quot;C:\PowerShell\output&quot;

$dbnames=@()

$msbuild=&quot;C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe&quot;

 $cdt=Get-Date

 #save output to a file
 $output=$output+ &quot;script executed at &quot; + $cdt + &quot;`r`n&quot;

 #also display the same interactively
 Write-Host &quot;script executed at &quot;  $cdt

 $output=$output +&quot;`r`n&quot;
 Write-Host

#load project list
 dir . -r  -include *.dbproj |where {$_.Name -notmatch &quot;server&quot;} |select-object fullname,name |
 % {

 $path=$_.fullname
 $dbnames +=$_.Name.replace(&quot;.dbproj&quot;,&quot;&quot;)
 $buildOutput=$buildOutput+&quot;\&quot;+$_.Name.replace(&quot;.dbproj&quot;,&quot;&quot;)

#for each dbproj file display its name
 $output=$output+ &quot;********** building &quot; + $_.fullname + &quot; ********************&quot; +&quot;`r`n&quot;
 write-host &quot;********** building &quot;  $_.fullname  &quot; ********************&quot;
 $output=$output+&quot;`r`n&quot;
 Write-Host

#execute the build and save output
 [string]$output1= &amp;$msbuild $path /nologo /verbosity:n /p:OutputPath=$buildOutput

 $output=$output+$output1 +&quot;`r`n&quot;
 $output=$output+&quot;`r`n&quot;
 $output=$output+ &quot;********** Finished building &quot; + $_.Name + &quot; ********************&quot; +&quot;`r`n&quot;

 #check if the build succeeded
 if ($output1.contains(&quot;Build succeeded&quot;))
 {
 Write-Host &quot;Build Succeeded&quot;

#display any warnings
$output1 | select-string -pattern &quot;\d+?\sWarning\(s\).+$&quot; |%{$_.Matches[0].Value}
 }

 #maybe it failed?
 if ($output1.contains(&quot;Build FAILED&quot;))
 {
 Write-Host &quot;Build Failed&quot; -foregroundcolor red

 #display build warnings
 $output1 | select-string -pattern &quot;\d+?\sWarning\(s\).+$&quot; |%{$_.Matches[0].Value}
 }
 Write-Host
 Write-Host &quot;********** Finished building &quot;  $_.Name  &quot; ********************&quot;
 $output=$output+&quot;`r`n&quot;
 $output1=&quot;&quot;
 $buildOutput=&quot;C:\PowerShell\output&quot;
}

 # save output
 Out-File -filepath $logpath -InputObject $output
</pre>
<p>to download <a title="DBA script to build a DB solution" href="http://bitwisemnm.com/blog/Downloads/MSBUILD.ps1">MSBUILD.ps1 as a file</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bitwisemnm.com/2012/01/building-your-database-solutions-outside-of-visual-studio/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
<enclosure url="http://bitwisemnm.com/blog/Downloads/MSBUILD.ps1" length="4416" type="audio/mpeg" />
		</item>
		<item>
		<title>SQL server powershell war chest &#8211; connection provider</title>
		<link>http://bitwisemnm.com/2011/12/sql-server-powershell-war-chest-connection-provider/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sql-server-powershell-war-chest-connection-provider</link>
		<comments>http://bitwisemnm.com/2011/12/sql-server-powershell-war-chest-connection-provider/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 20:24:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://bitwisemnm.com/?p=34</guid>
		<description><![CDATA[It is clear by now that MS SQL server and powershell are going to be good friends for a long time to come. So a prudent DBA should be building a war chest of script modules that can be reused &#8230; <a href="http://bitwisemnm.com/2011/12/sql-server-powershell-war-chest-connection-provider/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It is clear by now that MS SQL server and powershell are going to be good friends for a long time to come. So a prudent DBA should be building a war chest of script modules that can be reused in different cases. I will go through a series of short posts that will make every DBAs life easier and more productive.</p>
<p>let&#8217;s start with basics &#8211; connection provider. If you&#8217;re going to interface with a SQL server, you need to connect to it. Here is a very simple script that will do the job:</p>
<pre class="brush: powershell; title: ; notranslate">
#get_conection.ps1

param(
      [string] $datasource=&quot;myserveraddress&quot;,
	  [string] $database = &quot;MyDb&quot;,
	  [string] $authType = &quot;Integrated&quot;,
	  [string] $username =&quot;&quot;,
	  [string] $password=&quot;&quot;
     )

## Prepare the authentication information.
if ($authType -eq &quot;Integrated&quot;)
{
$authentication = &quot;Integrated Security=SSPI;&quot;
}
else
{ $authentication = (&quot;uid={0};pwd={1};&quot; -f $username,$password)	}

# Create the actual connection string
$connectionString = &quot;Persist Security Info=True;Initial Catalog=$database;Data Source=$dataSource;$authentication&quot;

## Connect to the data source and open it
$connection = new-object System.Data.SqlClient.SqlConnection $connectionString
$connection
</pre>
<p>As you can see, there is practically nothing to it. you can easily switch between SQL [regular] and Windows [integrated] modes of authentication. We&#8217;ll be using this script a lot in the future.</p>
<p><a title="Get_connection.ps1" href="http://bitwisemnm.com/blog/Downloads/Get_connection.ps1">Download Get_connection.ps1</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bitwisemnm.com/2011/12/sql-server-powershell-war-chest-connection-provider/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with suppress warnings in Visual Studio Database Solutions</title>
		<link>http://bitwisemnm.com/2011/12/working-with-suppress-warnings-in-visual-studio-database-solutions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-suppress-warnings-in-visual-studio-database-solutions</link>
		<comments>http://bitwisemnm.com/2011/12/working-with-suppress-warnings-in-visual-studio-database-solutions/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 21:03:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[DB Project]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://bitwisemnm.com/?p=17</guid>
		<description><![CDATA[MS Database Projects have come a long way from their humble beginnings especially with GDR and now full integration into VS2010, but plenty of issues remain. One of the more persistent problems is tracking references. Sometimes we just have to &#8230; <a href="http://bitwisemnm.com/2011/12/working-with-suppress-warnings-in-visual-studio-database-solutions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p class="Standard">MS Database Projects have come a long way from their humble beginnings especially with GDR and now full integration into VS2010, but plenty of issues remain. One of the more persistent problems is tracking references. Sometimes we just have to repress those warnings (code 4151). (<a href="http://msdn.microsoft.com/en-us/library/aa980442(v=vs.80).aspx">http://msdn.microsoft.com/en-us/library/aa980442(v=vs.80).aspx</a>) :</p>
<div id="graphics1" class="fr1" style="height: 2.8335in; width: 4.1563in; float: left; padding: 0; position: relative; left: 3.5169cm;"><img style="height: 7.1971cm; width: 10.557cm;" title="setting Suppress Warnings 4151 " src="http://bitwisemnm.com/blog/images/SuppressWarnings4151.JPG" alt="setting Suppress Warnings 4151 " width="399" align="alignnone" /></div>
<div style="clear: both; line-height: 0; width: 0; height: 0; margin: 0; padding: 0;"> </div>
<p>&nbsp;</p>
<p class="Standard">that&#8217;s all fine and good and gets us out of a bind short term, but if you really are going to use your DB project as intended, you should keep the number of objects that need this to a minimum. One problem is that once you set it, there is no visual way to identify a “suppressed” object. One way out of it is to parse the dbproj file. With Powershell, of course, it doesn&#8217;t get any simpler. Here is a script that I use. I&#8217;ve added comments for clarity:</p>
<pre class="brush: powershell; title: ; notranslate">
#H4151.ps1

$root=&quot;.&quot;
#check if the output file exists, if so delete it
IF (Test-Path c:\temp\output.csv)
{Remove-Item c:\temp\output.csv}

# Create a file header
$output=&quot;DBProject,SQLObjects `r`n&quot;

#get the files
$files=(dir $root -r | where {$_.extension -match &quot;dbproj&quot;}|Get-Item)
foreach ($file in $files)
{
#get the file naame
$ProjectName=$file.Name
$ProjectName

#get the second ItempGroup block
$fileString=Get-Content $file
$text_list=[regex]::Matches($fileString,&quot;&lt;ItemGroup&gt;(.*?)&lt;/ItemGroup&gt;&quot;) | Select-String &quot;SuppressWarnings&quot; | %{$_.line}

#let's add a root element to the list
$text_list=&quot;&lt;root&gt;&quot;+$text_list+&quot;&lt;/root&gt;&quot;

$xd=1$text_list

#get all the object Names
$xd.SelectNodes(&quot;/root/ItemGroup/Build[SuppressWarnings=4151]&quot;) | %{
$objName=($_.Include).split(&quot;\&quot;)[-1]
write-host $ProjectName,$objName;
$output=$output + $ProjectName + &quot;,&quot;+ $objName+ &quot;`r`n&quot;
}

}

Out-File -filepath c:\temp\output.csv -InputObject $output -Append
</pre>
<p>Download a <a title="DBA script to display objects with 4151 warnings suppressed" href="http://bitwisemnm.com/blog/Downloads/H4151.ps1">sample powershell script</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bitwisemnm.com/2011/12/working-with-suppress-warnings-in-visual-studio-database-solutions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

