Eggins.com
Powershell, .Net, Visual Studio, Team Foundation Server, Windows Communication Foundation

Browse Blog Posts by Tags

Showing related tags and posts for the Blogs application. See all tags in the site
  • Add event source using Powershell

    If you write to the event log from an ASP.Net application, the default ASPNET account will not have the correct privileges to add your event source. You have to add the event source outside of the ASP.Net application. I used to use a C# console application that I wrote for the purpose of registering...
    Posted to Software Development by David on 02-16-2008
    Filed under: Filed under: , ,
  • Converting the results of a Cmdlet to a formatted string

    There are times that you may want to store the results of a Cmdlet as a string instead of the usual collection of objects. This is handy to create a textual report. The following command stores the contents of C:\Windows into a varialble. $Result = dir c:\windows The $Result variable is a collection...
    Posted to Software Development by David on 08-16-2007
    Filed under: Filed under: , ,
  • Powershell function to split SQL Server stored procedure script file

    We do not yet have a good way to compare our Test and Production databases. This will be changing very soon. In the meantime, I have written the script below that may be of use for others without database compare tools. You can script all of the stored procedures in a SQL Server 2005 database to a "...
    Posted to Software Development by David on 05-31-2007
    Filed under: Filed under: , ,
  • Powershell one liner to see the progress of an install

    So I am installing the Visual Studio 2005 SP1, which takes up to several hours according to one of the early installer screens. I have had to install VS 2005 SP1 on several machines, and it has been known to become unresponsive during the install, requiring teh process to be killed. While waiting for...
    Posted to Software Development by David on 05-31-2007
    Filed under: Filed under:
  • Team Explorer

    I have been doing a bit of reasearch on Team Explorer. In the early beta vesions of VS.Net 2005, they iincluded Team Explorer in the VS 2005 install. When it became apparent that Team Foundation Server (TFS) was not going to be ready for release by the VS 2005 release date, they removed Team Explorer...
    Posted to Software Development by David on 05-30-2007
    Filed under: Filed under:
  • Quick and easy way to measure the length of a string

    If you want to quickly measure the length of a string, you can use Powershell. Just enclose the string in quotes and call the Length property. For example: "The quick brown fox jumped over the lazy dog".length "C:\Documents and Settings\All Users\Start Menu".length Even better, if...
    Posted to Software Development by David on 05-30-2007
    Filed under: Filed under:
  • Count the number of properties, methods, events, etc on all types in all assemblies loaded into Powershell

    While writing my earlier blogs on loading assemblies and finding types, I was playing around with the functions that allow me to count the total available members on all types in all loaded assembles. This may not be of great use, but it is interesting nonetheless. So this command will show the total...
    Posted to Software Development by David on 05-30-2007
    Filed under: Filed under:
  • Find paths longer than a given number of characters

    There are times where you may need to list the paths to files and folders which exceed a given number of characters. FAT, NTFS, CDFS, ISO DVD, FATX, and Novell Netware all have different limitations on the length of a path. It is helpful to know the paths that will exceed these limits when copying from...
    Posted to Software Development by David on 05-30-2007
    Filed under: Filed under:
  • Powershell function to locate a type

    My earlier posts on loading assemblies into Powershell gave me an idea for a useful Powershell function. I cannot remember the namespace for every type in the .Net framework, and all of our own custom business types. I have always wanted to have the functionality to locate a type, and get the namespace...
    Posted to Software Development by David on 05-29-2007
    Filed under: Filed under:
  • Load an assembly in Powershell Pt 2

    Yesterday I posted on adding an assembly to Powershell. You should be aware that if you load an assembly from the command line, it will only be loaded during that session. If you exit the command line, and run the Powershell command line again, you will not have that assembly loaded. If you have an assembly...
    Posted to Software Development by David on 05-29-2007
    Filed under: Filed under:
  • Get-Member is your friend

    One of the best cmdlets you can use while learning Powershell is Get-Member . This cmdlet will show all available methods and properties on any given type. If you execute the following command: "Hello" | Get-Member it will show the following (cut off at the right for brevity): TypeName: System...
    Posted to Software Development by David on 05-28-2007
    Filed under: Filed under:
  • What version of .Net is Powershell using?

    Here is a quick and easy way to find out what version of .Net Powershell is using. [Reflection.Assembly]::GetAssembly([String]) It uses the GetAssembly static method, passing in the .Net base class type of String.
    Posted to Software Development by David on 05-28-2007
    Filed under: Filed under:
  • Load an assembly in Powershell Pt 1

    By default, Powershell loads a bunch of assemblies for you so that you can start working with the base types, and some common functions. If you want to use the functionality in an assembly that is not already loaded, you will have to load that assembly yourself. I will describe this process in this blog...
    Posted to Software Development by David on 05-28-2007
    Filed under: Filed under:
  • Powershell Setup

    As you can tell, I am a big fan of Powershell. In this post, I will document my Powershell setup. This is mainly for my own notes, but if you can get something out of this, then well and good. I would expect this to change fairly rapidly, so I will be updating this post as my setup changes with the release...
    Posted to Software Development by David on 05-27-2007
    Filed under: Filed under:
  • Regular expressions in Powershell

    Here is a simple example of using Regular Expressions (Regex) in Powershell. It will find any string starting with "http://" and ending with ".com" # Set up the pattern to look for. This is a non-greedy search for http links in the "com" TLD $Pattern = [regex]"http...
    Posted to Software Development by David on 05-17-2007
    Filed under: Filed under: ,
  • Get HTML using Powershell

    The following powershell command uses the .Net library to download a HTML page from the web and displays it in the console. (New-Object Net.WebClient).DownloadString("http://www.eggins.com") You must include the protocol "http://" in the web address. This can also be used for ftp...
    Posted to Software Development by David on 05-17-2007
    Filed under: Filed under:
  • Powershell Date Formatting

    There are many date formatting options available to Powershell using the .net format specifiers. I will show some examples below, and you can look to the end of this post to see alla vailable format specifiers. To format a date to long date: "{0:D}" -f [DateTime]"7/14/2007" Produces...
    Posted to Software Development by David on 05-17-2007
    Filed under: Filed under: , ,
  • Powershell Number Formatting

    The number formatting features available to Powershell though the dot net String.Format() function are a lot more exciting than the string formatting mentioned in my last post. I will give some examples here, and you may look at the end of this post for more formatting specifiers. To pad a number with...
    Posted to Software Development by David on 05-17-2007
    Filed under: Filed under: , ,
  • Powershell String Formatting

    Powershell uses the .Net string formatting features in String.Format. The only formatting functionality for a string is the alignment. To left align a string and pad to 40 chars, the following two lines produce the same result: [System.String]::Format("{0,-40}", "MTB rules") "...
    Posted to Software Development by David on 05-17-2007
    Filed under: Filed under: , ,
  • A good collection of Powershell scripts for TFS

    This is a good collection of Powershell scripts for Team Fountation Server. http://blogs.msdn.com/jmanning/pages/various-powershell-scripts.aspx
    Posted to Software Development by David on 05-10-2007
    Filed under: Filed under: ,
  • Powershell - Get longest path length

    Windows has a path length limit of 255 chars. If you are going to copy a bunch of files around that are contained within a deep hierarchy, you run the risk of hitting this limit. To check the length of the longest file name including the entire path length, use this PowerShell script. cd "C:\MyDir"...
    Posted to Software Development by David on 04-03-2007
    Filed under: Filed under:
  • Drag-Drop to execute Powershell scripts

    Save this batch file to the HDD where your powershell script files are. You can then drag your powershell "PS1" files onto this batch file and they will be executed. REM ---------------- Start Batch file "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe\powershell.exe" -Command...
    Posted to Software Development by David on 02-21-2007
    Filed under: Filed under:
  • Powershell - Load 256 chars into char array

    All 4 of these Powershell lines do exactly the same thing . Load the first 256 chars into a char array. for ([int]$i = 0; $i -le 255; $i++) {$a += [char]$i}; 0..255|%{$a+=[char]$_} $a=0..255|%{[char]$_} [char[]]$a=0..255
    Posted to Software Development by David on 02-21-2007
    Filed under: Filed under:
  • Powershell - Create podcast download HTML

    Occasionally, I need to download many files from a single site, where all of the files are numbered. For example, catching up on podcasts. To make this easier, I would usually create a html file, listing all of the files as links, and then use the Firefox extension "DownThemAll" to download...
    Posted to Software Development by David on 02-21-2007
    Filed under: Filed under:
Page 1 of 1 (24 items)
Copyright eggins.com, 1998 - 2008
Powered by Community Server (Non-Commercial Edition), by Telligent Systems