December 2009 Entries

Program Files Environment Variable in PowerShell

Today I saw this on Twitter from Julie Blender (@#juneb_get_help): Need to reference the "ProgramFiles(x86)" environment variable in #PowerShell? Use ${env:ProgramFiles(x86)}. I use this in a lot of my scripts, but I want a single variable that contains the right value whether I'm in a 64 bit shell or not. Here's my solution: First, I have a function in my testing profile called is64bit, that looks like this: function is64bit() { return ([IntPtr]::Size -eq 8) } Next, I have a get-programfilesdir ......

Posted On Tuesday, December 29, 2009 7:27 AM | Comments (2)

GeeksWithBlogs and SubText Bloggers: Input string was not in a correct format

GeeksWithBlogs.net and other SubText Users: If you are trying to create a new blog post, and you get the following error: Input string was not in a correct format. at System.Text.StringBuilder.F... at System.Text.StringBuilder.A... provider, String format, Object[] args) at Subtext.Framework.Util.KeyW... source, String oldValue, String newValue, Boolean isFormat, Boolean onlyFirstMatch) at Subtext.Framework.Util.KeyW... entry) at Subtext.Framework.Data.Data... ......

Posted On Tuesday, December 29, 2009 4:42 AM | Comments (2)

10 PowerShell One Liners

Here are a few one-liners that use NetCmdlets. Some of these I've blogged about before, some are new. Let me know if you have questions, which ones you find useful, or how you altered these to suit your own needs. Send email to a list of recipient addresses: import-csv users.csv | % { send-email -to $_.email -from lance@nsoftware.com -subject "Important Email" –message "Hello World!" -server 10.0.1.1 } Show the access control list for a specific Exchange folder: get-imap -server $mymailserver -cred ......

Posted On Tuesday, December 29, 2009 4:36 AM | Comments (1)

PowerShell: Smart Parameter Expressions

A while back I posted about how to mark a script parameter as required in PowerShell. Shortly afterwards, there was some chatter on it that I think makes it worthwhile to add another post on the subject of PowerShell script parameters. Let’s say you have the question: “Can I do <X> with a parameter?” The answer is probably “Yes”. :) Jim and an anonymous emailer both asked: Is there any way you can specify a parameter based on the value of another parameter? The answer is yes. You can put pretty ......

Posted On Tuesday, December 8, 2009 1:49 AM | Comments (0)

Listing SPQuery FieldNameRefs

It took me a while to figure out how to get a list of all the available fields for a particular type of list in SharePoint (for performing custom queries in SPQuery). I was looking for a published list of these fields, which as far as I know does not exist. Instead, you just use the GetList method of the Lists SOAP service. Here’s an example SOAP request: <?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://sche... SOAP-ENV:encodingStyle="htt... ......

Posted On Monday, December 7, 2009 4:24 AM | Comments (0)

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski