Last year, I finally started working with SMO (SQL Management Objects) within PowerShell and I absolutely love it. Below are a few recipes that I created and use extensively throughout my SQL Management scripts on ScriptCenter. Some recipes show more than one way to perform a task. These SMO recipes are particularly …
Read MoreWhile researching how connect to a detached MDF and read the internal file structure of the internal files, including LDF files, I kept seeing suggestions for using the undocumented DBCC command DBCC checkprimaryfile. Initially, my code looked like this: 1# SQL Server is required to read the file contents 2$servername …
Read MoreHere are two straight-forward ways to create Scheduled Tasks within Windows using PowerShell. One script creates a PowerShell Scheduled Job, and the other creates a classic Windows Scheduled Task. You can read about the differences here. PowerShell v3 and above required. Create a Scheduled Job The following script …
Read MoreMicrosoft ConnectM isn't letting me sign in to post this workaround, but I just ran into a bug with the OleDbProviderSettings within SMO. To get around it, I used $server.Settings.OleDbProviderSettings instead of $server.OleDbProviderSettings 1$server.Settings.OleDbProviderSettings.Name.Contains("SQLOLEDB") …
Read MoreUsing a NetScaler within home lab is beneficial, mostly because you can use the same IP over and over for different services. Imagine providing VPN, Lync Autodiscover, Exchange Autodiscover, and SharePoint all over port 443. That's what a NetScaler VPX can do for you, for free. Below is a tutorial that will help you …
Read MoreTonight, I published Invoke-Locate.ps1 to ScriptCenter because I was tired of mounting my Windows drive to my Linux servers to quickly and reliably find files. Originally, it was going to be a small script, but then I decided to trick it out, add an installer and automatic Task Scheduling to run updatedb. The installer …
Read MoreI'm currently working on a PowerShell/SQL set of scripts to ease SQL Server Migrations. A few of the scripts have been posted to Microsoft's ScriptCenter. Recently, one of the ScriptCenter visitors asked: Can this script be used to backup all server configuration and restore at a later date. The use case I have is that …
Read MoreAbout 8 years ago, I wrote a blog post that provided a VBScript to create easy-to-read shortcuts to IIS Log directories. W3SVC56 just wasn't helpful enough to identify which website logs to which directory. Today, I ported that same script to PowerShell. I'm too lazy to explain, so this is what it does: Easy peasy. …
Read MoreOops! I forgot to tell my mom to resize her photos before uploading them to RealCajunRecipes.com. We had colossal 7MB+ images floating around on the web server, and SSD space doesn't come cheap. No problem, I just installed ImageMagick, backed up my directories, then ran the following command which finds all the 1MB+ …
Read MoreA buddy of mine was running into issues importing a 1 GB CSV of Longitudes and Latitudes available from geonames.org. The CSV contains over 9 million rows, and no matter what he did, DTS/SSIS would not import the data because of conversion issues. That's actually been happening to me a lot lately, too, so I find myself …
Read More