DOS PowerShell Tips

SVN checkout using BATCH and PowerShell

Few days back I was working on a script to automate project builds. And at one step I was required to checkout code from source control and build the application. Since everything was done using a single script there was no way I could prompt to user GUI because in this case it was just a plain PowerShell script. After bit to experimenting and Googling, I was able to find a solution that fit my need, but then I thought to use same script as a batch script (of course with some modifications) and I was surprised to see that many commands in PowerShell are declared and used differently then what we normally do in batch script. That was same case with SVN commands.

I use Tortoise SVN for both work and myself, so I am showing this using it. But if you look at help file it is clear that Tortoise SVN is more like a GUI tool not something that can be used via CLI, in fact it is even recommended by author himself to use Official SVN tools instead of Tortoise SVN. But lucky for us, Tortoise SVN already includes official SVN tools !! You can find them at “%ProgramFiles%\TortoiseSVN\bin\”, it includes exes like SVN, SVNAdmin, SVNLook, SVNVersion etc. If they are not there then most likely they are excluded during installation (which is default installation choice). So just grab installation EXE from Tortoise SVN site and run installer again to install these tools.

PowerShell Tips

Powershell … shell on steroids !!

Shell is not a new thing for any older timer … or for folks working with forbidden OSes like Unix and Linux. It is primary utility used by users to interact with those systems (and in older days it was perhaps the only way of interaction). Till few days back, I was obsessed with DOS and batch files. And I tried to do most of system automation tasks using them. I even received comments from Boss, that I can do better if I use PowerShell instead of DOS. But like some old lady obsessed with her old hat or something, I was reluctant to give away old love for DOS.

But recently I went to local Access user group meeting here at CT. And there was presentation for “Introduction to PowerShell for Database Developers”. And I realized that all this time I was just ignorant to not to use PowerShell. You have whole .NET stack for you to consume in addition to support of both DOS and Unix Shell commands !! In simple words, PowerShell is really A Shell on Steroids.

And with this new “inspiration” I have decided to give PowerShell a try and use it for automation tasks in newer systems (mostly Post Windows Server 2003 R2).

Couple of days back, I created a VB Script to send email notification to users using any  publically available SMTP servers like Google or Yahoo. That script was actually using built in class “CDO.Message” for configuration and sending email. This can be in done same manner by creating simple .NET console application just like below,

[csharp] MailMessage message = new MailMessage();
message.Subject = "Test Subject for Email";
message.From = new MailAddress("fromMail");
message.Body = "Message from Google SMTP";
SmtpClient smtpG = new SmtpClient("");
smtpG.EnableSsl = true;
smtpG.Port = 587;
System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential("loginEmail", "password");
smtpG.Credentials = mailAuthentication;
Console.WriteLine("Mail sent using Gmail");
Console.ReadLine(); [/csharp]