PowerShell

There are 93 entries for the tag PowerShell

Merge Delimited Files on a Common Key

Many times I need to merge two separate datasets that have a common key column – for example: dataset 1: ID, Name, Weight, Height dataset 2: ID, Address1, Address2, Phone1, Phone2 I can’t just concat the data together, instead I need the merge to happen around the ID key, so that each ID only has a single row in the result. So, of course I wrote a powershell script to do this for me. Take a look at it below. I called it “Merge-TsvFiles”, but it takes a delimiter as one of its paramters, so you could ......

Posted On Tuesday, October 18, 2011 1:17 PM | Comments (7)

How Expedia Made My New Bride Cry

If you would like to help me out, you can Tweet this story OR email Expedia and ask them to make things right for me and my wife. This is the story of how Expedia made my new bride cry. When Expedia followed up their failure with our honeymoon trip with a complete and total lack of acknowledgement of any responsibility for the problem and endless loops of explaining the issue over and over again - I swore that they would make it right. When they brought my new bride to tears, I got an immediate and ......

Posted On Sunday, June 19, 2011 10:00 AM | Comments (21)

Using Team Foundation 2010 PowerShell Cmdlets

add-pssnapin Microsoft.TeamFoundation.PowerShell

get-command -module *TeamFoundation*

Posted On Monday, May 2, 2011 12:37 PM | Comments (0)

Creating Team Foundation Work Items With PowerShell

Here is the simple function I added to my powershell profile: function create-tfstask ($desc) { tfpt workitem /new $workItemType /collection:$serverUrl /fields:"Title=$($desc);Ass... To=$assignee;AreaId=$areaId... } To find the AreaId and IterationId for your project/versions, just look at a bug you know is setup correctly: PS C:\> tfpt query /collection:http://3bs001vs... /wiql:"select AreaId,IterationId from workitems where ID = 879" Next I hooked this into ......

Posted On Wednesday, January 26, 2011 10:58 AM | Comments (1)

Quick PowerShell “Todo” Gmail Emailer

I put the following function in my PowerShell profile so that I can just bring up my PowerShell console and type myself a quick “todo” note that automatically gets emailed to me for later. There are several things of note in this tiny script: 1. Note the use of the $args variable to effectively allow the user to enter $msg parameter without quotes even if it contains whitespace. 2. In this particular example I’m sending the email through Gmail. smtp.gmail.com, port 587, SSL and authentication required. ......

Posted On Tuesday, October 26, 2010 1:27 PM | Comments (4)

PowerShell TruncateAtWhitespace Function

Here’s a TruncateAtWhitespace function that takes an incoming parameter value and an incoming max length, and returns a substring broken at a whitespace position. This way if you have “Lance has a blog” and you need to truncate it to 8 characters or less, you get “Lance” instead of “Lance ha”. function TruncateAtWhitespace{ param( [string]$value, [int]$maxlength=200 ) $maxlength-=3; #allow for "..." suffix if ($value.Length -le $maxlength) { return ($value + "..."); } $closestwhitespaceindex = [int]$value.Substring(0, ......

Posted On Monday, August 16, 2010 3:30 PM | Comments (0)

Leaving /n software, headed to new startup

I've been extremely fortunate to work at /n software, but after more than 9 years, the time has come for me to say "goodbye". This Friday will be my last day. The people behind the amazing machine that is /n software are great, hard working people, and I'll be a fan for life. Most importantly though, I'm looking forward to new experiences and new challenges. I'll be joining an exciting new online marketing startup in Chapel Hill (more about them later!). My new work will be as a C# developer, but ......

Posted On Thursday, March 18, 2010 9:56 AM | Comments (2)

Automatic NUnit Test Generation with PowerShell + XML

First, I’ll describe a process I’ve been using for the last couple years to manage integration testing. After that, I’ll talk about a new requirement for integration and unit testing, and how I altered things to accommodate the new requirements. The Last Two Years For the last two years I had a small set of Powershell scripts that allowed me to make sure my integration tests are using the latest libraries compiled with the latest source, and using the latest nunit test code. Testing_profile.ps1 – ......

Posted On Friday, February 26, 2010 3:59 PM | Comments (0)

Exception setting "ThreadOptions" in SharePoint 2010 Management Shell

Right after you install SP2010 (Foundation or Server), even on a completely updated Windows Server 2008 SP2, when you go to start the SharePoint 2010 Management Shell (the recommended PowerShell interface for working with SharePoint), you get a real ugly looking error: Exception setting "ThreadOptions": "This property cannot be changed after the Runspace has been opened." At C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONF IG\POWERSHELL\Registration\... char:48 ......

Posted On Wednesday, February 17, 2010 1:56 PM | Comments (1)

PowerShell: Twitter Auto UN-follow

Anybody who uses Twitter has heard of auto-follow services for Twitter. Below is a PowerShell script I used to auto UNfollow. The script goes through the people you're following and eliminates "idle" or "spam" friends. An idle friend is determined by a low friend count or low status count on an account that has been in existance for at least a couple months (configurable). A spam friend is determined by a high friend count but a low follower count (by default, the script uses a 15-1 ratio as the ......

Posted On Tuesday, January 12, 2010 1:06 PM | Comments (4)

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)

10 DIY SharePoint Web Parts #8

This post is the eighth in a series of postings, containing examples of SharePoint WebParts that anybody can build all by themselves. To read all posts in this series, or to get started with the RSSBus WebPart, go here. #8 – Twitter Many times since I originally posted about it months ago, I’ve been asked for more details about including Twitter searches and streams inside their SharePoint pages. Thanks to the Twitter API and feeds, this is very simple to do, and to change from showing searches, ......

Posted On Friday, October 30, 2009 3:35 AM | Comments (2)

PowerShell Command Line Emailer

I’ve talked about this before, but it came up again today so I thought I’d do a quick post about it. Here’s a function I use in my PowerShell profile that uses NetCmdlets to send quick “todo” emails: function todo($target="work", $msg) { switch ($target) { "work" { $target = "lancer@nsoftware.com" } "home" { $target = "lmrobins@gmail.com" } } send-email -from lancer@nsoftware.com -to $target -subject ("Todo: " + $msg) -message $msg -server 10.0.1.1} During the day, when I need to send myself a reminder, ......

Posted On Tuesday, October 20, 2009 8:07 AM | Comments (0)

5 PowerShell Oneliners to Manage IMAP Permissions

You can manage user permissions in Exchange and other mail servers with the same commands by using the IMAP protocol instead of server-specific tools. Here is how! Jumping right in, these all use get-imap and set-imap from NetCmdlets: #1 – Get ACL Here’s a one-liner to get the ACL for a specific folder in an account. In this particular case, my main INBOX has a subfolder named RESUMES, and I want to see who has what permissions to this folder. PS C:\> get-imap -server $mymailserver -cred $mycred ......

Posted On Thursday, June 4, 2009 11:11 AM | Comments (0)

Get the number of current SharePoint connections

Here is a PowerScript function to automate the process of getting/logging the current number of connections to a particular Web Server. It will tell you the number of connections for each site on the server, so you can see the number of SharePoint connections, SharePoint Central Admin connections, etc. Thanks to MOW and Lee Holmes for their examples of using the PerformanceCounter class in PowerShell. function Get-WebServiceConnections(){ $results = @{} $perfmon = new-object System.Diagnostics.Performa... ......

Posted On Wednesday, June 3, 2009 10:29 AM | Comments (1)

Troubleshooting FTP connections with PowerShell

I find that helping people troubleshoot FTP connectivity issues is much easier if they have PowerShell installed. I can just have them run the NetCmdlets ftp cmdlets with the –debug switch, which displays a trail of information about the communication over the wire. In this way you can see every command send to the server and every response coming back from the server, including what ports a server is attempting to use for ftp data connections. Very often ftp transfer connectivity errors are the ......

Posted On Thursday, May 21, 2009 1:22 PM | Comments (0)

Managing MS Exchange Remotely From Unix, Phone, Windows, etc.

Recently I saw a question come to my friend Spencer here at /n software about whether or not it was possible to use the Microsoft Exchange 2007 SP1 PowerShell cmdlets through the /n software PowerShell Server. The person wanted to be able to manage Exchange from a remote Unix machine. Of course, as I’ve mentioned before, it could be done from anywhere that supports SSH – like an Apple iPhone or a Blackberry. The PowerShell server uses impersonation - it impersonates the user that the SSH client authenticated ......

Posted On Wednesday, May 6, 2009 12:55 PM | Comments (1)

PowerShellRSS Automatically Converts PSObjects to RSS Items

In a previous post, I talked about how PowerShellASP can be used to generate an RSS feed with PowerShell. Now I’ll show how the same feed can be generated more easily with PowerShellRSS. Again, the dir command in PowerShell (get-childitem) is used to get a listing of files to use as enclosures in the feed. # This example demonstrates how to generate an RSS feed from a call to the Get-ChildItem cmdlet (dir). # To tailor to your specific needs, set the following values: $mediadir = 'C:\Testing\media';$virtual... ......

Posted On Tuesday, May 5, 2009 5:42 PM | Comments (1)

PowerShell Prompt inside SharePoint

Using the PowerShellToys PowerShellWebPart, I was able to insert a PowerShell command prompt inside my SharePoint page with only a few lines of code and some html. Here is the PowerShellWebPart template that I used: <div style="background-color:Dar... color:white; height:400px; width:650px"> <form method="GET" action="" enctype="multipart/form-dat... PS> <input type=text name="query" size="40" value="<%=$request['quer... /> <input type=submit value="Execute" /> ......

Posted On Tuesday, May 5, 2009 3:47 PM | Comments (0)

New Toys for PowerShell!

At PowerShellToys.com, you’ll find a bunch of new toys for PowerShell, including the first full release of PowerShellASP + free community license. The new toys? PowerShellADO, PowerShellPanel, PowerShellWebPart, and PowerShellRSS. Here’s a brief description of each, in my own words. For the official description and examples, check out PowerShellToys.com. PowerShellASP – write ASP pages with PowerShell scripting instead of vbscript. PowerShellADO – execute PowerShell cmdlets and return the results ......

Posted On Monday, May 4, 2009 5:00 PM | Comments (1)

PowerShellASP – Generate an RSS feed from PowerShell cmdlets

PowerShellASP is a powerful tool for generating web pages with PowerShell. It allows you to insert PowerShell script directly into a webpage (a .ps1x page), that code will be executed and the resulting powershell objects are renderable in your page. It also exposes familiar $response, $request, $server, etc. for accessing response, request, and other information about the HTTP context. This example shows how to use PowerShellASP to generate an RSS podcast feed. The dir command in PowerShell (get-childitem) ......

Posted On Tuesday, April 21, 2009 3:08 PM | Comments (2)

Tweets In SharePoint

I saw Michael @Gannotti’s Tweets Wiki and thought it was pretty handy. It made me think of @jazzychad’s TweetGrid and how that would be nice inside SharePoint. So I combined these two into my own little twitter search page in SharePoint, and here’s how: Tools I used: RSSBus SharePoint WebPart. Installed and activated the RSSBus SharePoint WebPart, added the webpart to my SharePoint page. I went to search.twitter.com, and did a search for “PowerShell”. The results page includes the RSS feed for the ......

Posted On Tuesday, April 21, 2009 12:57 PM | Comments (0)

Get-Ldap NetCmdlet in PowerShell

I saw Jeff Hicks’ great Get-LocalMember post this morning, in which he has extensive demonstration of retrieving information about AD group members. I thought it might be a good time to show some of the power of the get-ldap cmdlet. Yes, using the get-ldap cmdlet does require familiarity with the LDAP protocol itself, so in this way it is for more advanced users who just need to do quick LDAP operations without a lot of required coding and with just one universal cmdlet. So, how do I list the group ......

Posted On Thursday, April 9, 2009 11:29 AM | Comments (2)

How RSSBus is useful in PowerShell

PowerShell users are scripters and developers who love productivity tools. That’s why you and I like PowerShell – it gives us so much to help us work more efficiently. RSSBus is another swiss-army knife of technology along this same vein, and is a handy complement to PowerShell. The biggest wins? #1, RSSBus makes it easy to get data. No matter the source of the data (tons of sources are supported already, with many more to come and an open interface so anybody can build more data connectors), with ......

Posted On Friday, April 3, 2009 12:26 PM | Comments (1)

PowerShell Custom Formatter for Mystery Objects

I needed to create a custom output formatter that would work for any object. Since I need it to work with any object, that means I won’t know before hand what properties the object has, or which of those properties I want to actually output. So, I couldn’t use any of the existing PowerShell format cmdlets like format-table, format-list, or format-custom. Instead, I needed to look at each object, get a list of its properties and their associated value(s), and then loop through those and display them ......

Posted On Friday, April 3, 2009 11:33 AM | Comments (0)

I’ll be a guest on the PowerScripting Podcast

I’ll be a guest on the extremely informative PowerScripting Podcast this Thursday evening (4/2/09). I’ll talk about some of the PowerShell-related products I am working on at /n software like NetCmdlets, RSSBus, PowerShell Server, as well as join in on some general PowerShell geek fun. Also I’ll give a sneak peak of some new freebie PowerShell toys coming out for PowerShell enthusiasts. Join in on the live UStream at 9pm EST Thursday and say “hi” – or download the podcast later from the PowerScripting ......

Posted On Monday, March 30, 2009 12:28 PM | Comments (1)

PowerShell: sync system time with Internet time server

NetCmdlet’s get-time cmdlet uses the Internet TIME protocol to query Internet time server’s for the current time. It can also be used to sync the time on the local system with that of the time server. The following PowerShell function gets the time on a time server, optionally syncs the local system to that time, and outputs both times to the console: 1: function sync-time( 2: [string] $server = "clock.psu.edu", 3: [int] $port = 37, 4: [switch] $set = $false) 5: { 6: $servertime = get-time -server ......

Posted On Monday, March 30, 2009 10:13 AM | Comments (1)

Twitter Search Web Part for SharePoint

1. I installed and activated the RSSBus Web Part for SharePoint, which allows me as a SharePoint owner or member to create a customized web part from one of dozens of RSSBus connectors or any RSS/Atom feed I like, such as a Twitter Search RSS feed. 2. I added the RSSBus Web Part to my SharePoint page, and edited its content using the Source Editor. I am using the following template to format the results of my search.twitter.com RSS result: <rsb:call op=http://search.twitter.co... ......

Posted On Friday, February 20, 2009 11:00 AM | Comments (1)

PowerShell function to determine if running on 64 bit machine

Easy a pie: function is64bit() { if ([IntPtr].Size -eq 4) { return $false } else { return $true }} Explanation: the size of an IntPtr will be 4 bytes on a 32 bit machine and 8 bytes on a 64 bit machine. I came across the tip somewhere (blog, usenet??) but I couldn't find it again - so I thought I'd share it here for anybody else who is looking for it. Technorati Tags: PowerShell ......

Posted On Friday, February 20, 2009 10:21 AM | Comments (3)

SharePoint Admins – You Dont Want to Miss This

The RSSBus SharePoint Web Part might just be the most exciting thing I’ve had the pleasure to work with in quite a while. RSSBus is an amazingly powerful product, but the RSSBus SharePoint Web Part…its just a thing of beauty. What the web part does: it lets you expose data from just about anywhere inside SharePoint. The simplest example is to show an RSS feed like Google News or Yahoo News. I tweeted about that last week. I put together two more simple examples. One is using my Twitter Search RSS ......

Posted On Friday, February 6, 2009 5:04 PM | Comments (0)

Pass by Reference Parameters in PowerShell

A long time ago Jeffrey Snover briefly mentioned the PowerShell [REF] parameter attribute, but otherwise there isn’t much mention around about how to use it. It seems simple enough, but I kept getting this error from PowerShell: “Reference type is expected in argument.” This post by MOW cleared things up for me – I needed to wrap my [REF] parameters in parens in the function call, like so: Find-NewMessages $valvar1 ([REF]$refvar1) ([REF]$refvar2) For those looking to see how pass by reference params ......

Posted On Wednesday, January 14, 2009 5:06 PM | Comments (3)

PowerShell Server v2 vs PowerShell v2 Remoting via WinRM

A lot of people have asked me to explain the differences in the PowerShell Server v2 product with the obvious alternative: PowerShell v2 Remoting via WinRM. PowerShell Server The nutshell is that with the PowerShell Server, you are not limited to Windows machines and you don’t need WinRM or any other software other than the PowerShell Server itself and any old SSH client. This means that the “client” machine, where the commands are being sent from, can be anything – a Linux machine, a handheld device ......

Posted On Friday, January 9, 2009 3:16 PM | Comments (4)

How to Execute SQL PowerShell Commands Anywhere

SQL Server 2008 PowerShell Cmdlets + /n software PowerShell Server v2 = Execute SQL Queries Anywhere. If you don’t already have the SQL cmdlets for PowerShell, you’ll need to download and install SQL Server 2008. A warning for those of you running on x64 machines - you’ll have to export the SQL Server keys in HKEY_LOCAL_MACHINE\SOFTWARE... (there should be 2 in PowerShellSnapIns and 1 in ShellIds) and reimport them to Wow6432Node. If you don’t already have /n software’s PowerShell ......

Posted On Monday, December 22, 2008 3:13 PM | Comments (3)

New NetCmdlets and PowerShell Server Releases

The new NetCmdlets v2 and PowerShell Server v2 are now available! NEW: NetCmdlets V2 and PowerShell Server V2 NetCmdlets V2 is packed full of exciting new features including Parameter Sets, Object Pipelining, and new Cmdlets for SSH connectivity and Amazon Web Services (S3) Integration PowerShell Server instantly enables Windows desktops and servers with an SSH secured PowerShell host entrypoint. Try out the new featues in NetCmdlets V2 and PowerShell Server: download a 30-day trial! If you are already ......

Posted On Monday, December 22, 2008 3:08 PM | Comments (1)

Executing PowerShell commands from iPhone and Linux?

Update: Here is how I did it, with the published version of PowerShell Server: http://geekswithblogs.net/L... I was talking to Richard Giles at Idera today and he made me realize that I’d never blogged about running PowerShell commands from my secondary Linux desktop, and from the iPhone. Here are the pictures, I posted them on Flickr a while back. This is done by using /nsoftware’s PowerShell Server (currently awaiting v2 release ......

Posted On Wednesday, November 19, 2008 3:01 PM | Comments (2)

PowerShellPlus

So I’ve been using PowerShellPlus for the last few days, and in short – its awesome. The ability to put my script editor on one monitor, click run right there and see the results of the script on the other monitor made me very happy. :) If you haven’t checked it out, you definitely should. Its basically an integrated development environment for PowerShell scripting and debugging. A PowerShell console combined with an editor complete with watch window and step-through debugger. As soon as you type ......

Posted On Wednesday, October 8, 2008 10:24 AM | Comments (1)

Deleting emails from PowerShell

The question was posed on the newsgroup: how do I delete emails (over POP or IMAP) on a remote mail server through PowerShell? Here’s an example of one way to do it – through the use of the get-imap, set-imap, and get-pop cmdlets that are included in NetCmdlets. ## deleteemail.ps1: Delete all email from a particular sender ## deletes emails from an IMAP or POP server. ## Returns a collection of objects containing information about deleted emails (from, to, subject) or mailboxes (name, flags) in a ......

Posted On Wednesday, September 24, 2008 3:44 PM | Comments (0)

PowerScripting Podcast

If you’re into PowerShell at all and you haven’t listened to the PowerScripting Podcast, you should definitely check it out. I know you’ve seen me write about the show before, but I also know that alot of us don’t have time to listen. Try downloading a copy and burning it onto a cd for your drive home, or copy it onto your mp3 player. The show is done by Hal Rottenberg and Jonathan Walz, two great guys who are a big part of the PowerShell community and who work hard putting together a great show. ......

Posted On Friday, September 19, 2008 10:08 AM | Comments (0)

PowerShell: ESPN-Download

“Quintas" was another of the winners of the PowerScripting Podcast’s NetCmdlets scripting contest. Quintas submitted an espn-download script, which retrieves podcast feeds from espn.com and downloads the mp3 files for later listening. Here is Quintas’ script: # ESPN-Download param($DownloadDir=$(throw "Usage: ESPN-Download.ps1 DownloadDirectory Show LatestorAllDownloaded`nShow... Mike & Mike`n2. PTI`n3. Around The Horn`n`n[L] for latestshow or [ A ] for All shows`n"), [string]$ESPNShow=$(Read-Host ......

Posted On Thursday, September 11, 2008 4:46 PM | Comments (0)

PowerShell NetCmdlets -debug

Its easy to forget about the –debug parameter, but a lot of times it can be very helpful, especially with NetCmdlets where in many cases –debug will output the protocol interface (the “PITrail” as we call it at /n software) of the connection. The PITrail includes a trail of communication between the cmdlet and the remote host it is talking to. Rob emailed me to ask for help diagnosing a 425 error he was getting when using the NetCmdlets get-ftp cmdlet. As I described to Rob, in a nutshell the 425 ......

Posted On Thursday, September 11, 2008 4:41 PM | Comments (0)

PowerShell: tweet-im

Mark Schill was another of the winners of the PowerScripting Podcast’s NetCmdlets scripting contest. Mark submitted a tweet-im script, which sends an instant message about new tweets found in the Twitter RSS feed. They explained on the podcast that Twitter used to have an IM-bot feature which went away, so Mark created this script himself to meet this need. The script simply sits and fetches your Twitter friends timeline feed every x seconds, checks to see if the items it finds are newer than the ......

Posted On Thursday, September 11, 2008 10:56 AM | Comments (0)

PowerShell: send-gmail

Over at the PowerScripting Podcast, the winners of the NetCmdlets scripting contest were announced. Meanwhile I was having some awesome vacation time in the beautiful Outer Banks of North Carolina. Winners for the /n software Netcmdlets contest are: Steve Hiner - Wrote a wrapper for Send-Email script to send email using Gmail's SMTP server Mark Schill - Sent in two entries, the one we've chosen to highlight is his Twitter IM client bot thingy. It uses Send-IM and Get-Http Quintus - A script to download ......

Posted On Wednesday, September 10, 2008 5:28 PM | Comments (0)

PowerShell – Base64 Encode/Decode a string

An easy way to convert data to/from base64 (or uuencode/uudecode, quoted-printable, url encode/url decode, JIS, Yenc, hex, or even creating md5 or sha1 hashes) is to use the NetCmdlets convert-data cmdlet. To encode: PS C:\> convert-data -data "Hello, World!" -to base64 Data Size Format ---- ---- ------ SGVsbG8sIFdvcmxkIQ== 20 base64 To decode: PS C:\> convert-data -data $encoded.Data data -from base64 Data Size Format ---- ---- ------ Hello, World! 13 Plain Technorati Tags: PowerShell, NetCmdlets, ......

Posted On Friday, August 29, 2008 1:24 PM | Comments (0)

New PoshBoard Release

The latest from Antoine Habert is that PoshBoard 0.3 is out at codeplex. He's posted release notes and a quickstart on his blog. update: fixed links. Technorati Tags: PowerShell, PoshBoard ......

Posted On Tuesday, August 26, 2008 9:54 AM | Comments (0)

test-remotepath.ps1

One of the cmdlets I use most often in my scripts is test-path, which simply tells you whether or not a particular file or path exists. Below is test-remotepath, which I use to tell me if a remote file or path exists. This particular script uses get-ftp from NetCmdlets, but it could also just as easily be done with rexec, rshell, or even ssh (sexec). ## test-remotepath.ps1: Tests if a remote file/path exists ## This script uses ftp to determine whether or not a remote file or path exists. ## This ......

Posted On Monday, August 25, 2008 5:23 PM | Comments (1)

PowerScripting Podcast – Scripting Contest!

Update: deadline pushed back (another week?) for the scripting contest. In case you missed it, the guys over at the PowerScripting Podcast are hosting a scripting contest. Hurry though, the deadline is Sunday! They’re giving away free licenses of NetCmdlets and PrimalScript 2007. Technorati Tags: PowerShell, NetCmdlets ......

Posted On Friday, August 15, 2008 11:04 AM | Comments (0)

NetCmdlets Invoke-Telnet?! And other PowerShell madness.

On last week’s PowerScripting Podcast, Jonathan Walz and Hal Rottenberg interview /n software’s Eric Madariaga about NetCmdlets and PowerShellToys (PowerShellASP). My favorite part was when Hal was shocked to hear that a telnet cmdlet was added to the v2 beta. Hahaha. I completely agree – who uses telnet anymore? But that was actually the biggest request we got from people who were using v1 of NetCmdlets! We already had cmdlets for executing commands over ssh…but people really wanted telnet. This ......

Posted On Monday, August 11, 2008 4:57 PM | Comments (1)

RAR and Other Alternative/Annoying Archival/Compression Formats

I hate when people send me an email with a .rar (or similar non-.zip) attachment. I realize that rar has some special features that set it apart - but those features are not really very important when you're just talking about sending me a small non-commercial c# project in an email. I think I will create my own custom compressed archival format, and start sending out .lnc files (which doesn't stand for "lance", but something creative that implies its the worst compression format ever, like "loco ......

Posted On Friday, July 25, 2008 11:23 AM | Comments (7)

New Stuff on the Work Front

From the work front: What have I been doing at work lately? I’ve been spending a lot of time at work playing with SharePoint, the PowerShellToys’ PowerShellASP which lets you create ASP.NET apps with PowerShell script, and I set myself up with a brand new openSUSE 11 (this is a great distro) machine where I’ve been spending a lot of time in MonoDevelop. Speaking of PowerShell and ASP.NET – check out PoshBoard [at CodePlex], Antoine Habert’s PowerShell driven ajax portal. Antoine has a nice little ......

Posted On Tuesday, July 22, 2008 12:27 PM | Comments (0)

NetCmdlets SFTP - Public Key Authentication in PowerShell

In the past I gave examples of using the get-ftp and send-ftp cmdlets for PowerShell, but recently a user pointed out that I didn’t show any examples of public key authentication using the cmdlets. Of course the –ssh flag tells the get-ftp and send-ftp cmdlets to use SSH (instead of plain text FTP, or an SSL connection which is turned on with the –ssl flag). For SSH connections, the AuthMode parameter determines what type of SSH authentication to perform – in this case that will be “publickey”. The ......

Posted On Wednesday, June 25, 2008 10:29 AM | Comments (0)

RSSBus: Simple Ways to Connect Data

I just uploaded a new YouTube video for RSSBus. Some of it is hard to see, but soon it will be published at rssbus.com as a high quality flash video. RSSBus can be used to securely serve custom feeds over the Internet or on the local host. This video shows examples of very basic feeds that can be created with RSSBus with just a few mouse clicks, and more complex piped feeds. Near the end, the video shows some ways in which RSSBus can be integrated into real world solutions. Obviously, RSSBus can ......

Posted On Tuesday, May 6, 2008 2:57 PM | Comments (0)

Free NetCmdlets license

/n software's NetCmdlets is available for free for non-commercial use. Check out the NetCmdlets hobbyist license here. Update! The ordering process does not require a credit card unless you request a physical cd shipment. For electronic download, just be sure to enter your name and email address! Technorati Tags: NetCmdlets, PowerShell ......

Posted On Tuesday, January 15, 2008 3:17 PM | Comments (4)

PowerShell script - marking a parameter as required

param( [string] $optionalparam1, #an optional parameter with no default value [string] $optionalparam2 = "default", #an optional parameter with a default value [string] $requiredparam = $(throw ""requiredparam required."), #throw exception if no value provided [string] $user = $(Read-Host -prompt "User"), #prompt user for value if none provided [switch] $switchparam; #an optional "switch parameter" (ie, a flag) ) Technorati Tags: PowerShell ......

Posted On Friday, December 14, 2007 12:57 PM | Comments (12)

NetCmdlets Cheat Sheet - again

Of course the day after I posted the NetCmdlets Cheat Sheet for PowerShell and then went on Vacation to the Outer Banks, the website where the cheat sheet was hosted went down.  Doh!  Its back up now!

Posted On Monday, September 10, 2007 5:41 PM | Comments (0)

NetCmdlets Cheat Sheet (PowerShell)

Last winter, Ben Pearce put together a little PowerShell Cheat Sheet. I printed it out and I keep it handy at my desk. It occurred to me that a NetCmdlets cheat sheet would be useful too, so I borrwed Ben's style and did just that. NetCmdlets Cheat Sheet - .docxNetCmdlets Cheat Sheet - .doc If you see something missing or if there are mistakes, let me know and I will update here. Technorati Tags: PowerShell, NetCmdlets ......

Posted On Friday, August 31, 2007 6:09 PM | Comments (0)

LDAP PowerShell User Account Control

The userAccountControl attribute is used to control the access of a user account. This value can be set to the bitwise OR of a set of flag values, documented here: Property flag Value in hexadecimal Value in decimal SCRIPT 0x0001 1 ACCOUNTDISABLE 0x0002 2 HOMEDIR_REQUIRED 0x0008 8 LOCKOUT 0x0010 16 PASSWD_NOTREQD 0x0020 32 PASSWD_CANT_CHANGE Note You cannot assign this permission by directly modifying the UserAccountControl attribute. For information about how to set the permission programmatically, ......

Posted On Wednesday, August 22, 2007 1:22 PM | Comments (1)

Adam Bell's PowerShell Toolbox

Adam's list of PowerShell tools.

Posted On Tuesday, August 21, 2007 4:10 PM | Comments (0)

Retrieve Remote MAC Address in PowerShell

Shay Levi played off my mac address retreival code yesterday and shared his own PowerShell script to retrieve a mac address. Here's another PowerShell script to retrieve a mac address using get-snmp from NetCmdlets: ## Retrieves the MAC address of an snmp-enabled device ## Returns a hex string that is the MAC address ## ## usage: get-mac [-agent] <string> ## param( [string] $agent = "10.0.1.11" ) #a function to convert an octetstring into a hex string function get-hex($octectstring) { $len ......

Posted On Tuesday, August 21, 2007 9:52 AM | Comments (4)

How to Retrieve Remote MAC Address Programmatically

The question often comes up, how do you find out the MAC address of a remote machine, given its IP address? There are a few ways to do it, but here are two: The first way is to use SNMP. Use whatever SNMP library you like, or create your own. Here are the steps you'll need to take, as well as an example showing how to implement these steps using IP*Works! or IPWorks Secure SNMP. Get the number of interfaces on the device (ifEntryNum - 1.3.6.1.2.1.2.1) For each interface, get the MAC address (ifPhysAddress ......

Posted On Monday, August 20, 2007 5:26 PM | Comments (10)

LDAP PowerShell - Search for Disabled User Accounts

PS C:\> get-ldap -server testboy -cred $mycred -dn dc=JUNGLE -searchscope wholesubtree -search "(&(objectclass=user)(o... Again, there's no need for dozens of LDAP cmdlets. The two LDAP cmdlets included in NetCmdlets, get-ldap and set-ldap, are all you need for most tasks. The above command shows how you would search for disabled user accounts with the get-ldap cmdlet. Technorati Tags: PowerShell, LDAP, Active directory, ......

Posted On Tuesday, August 14, 2007 10:51 AM | Comments (0)

LDAP - Change Group Membership

In my previous posts about LDAP group membership, I've talked about how to get a list of groups, how to search for a particular groups members, and how to search for what groups a particular user belongs to. Up next: how to change group membership. To add or remove a user from a group, you need to modify the "member" attribute of the group itself. To do this we'll use the set-ldap cmdlet of NetCmdlets. Add a user to a group: To add a user to a group, set the DN parameter of set-ldap to the DN of ......

Posted On Monday, August 6, 2007 10:22 AM | Comments (2)

LDAP - Search for What Groups a Particular User Belongs to

In the last LDAP series post, I mentioned how to search for the members of a group. Now the opposite, here's how to search for what groups a particular user is a part of: To do this search, all I do is form a search filter that is searching for all groups that has a particular member in it. So really this is a slight alteration of the search for all groups. PS C:\> get-ldap -server testboy -cred $mycred -dn dc=JUNGLE -searchscope wholesubtree -search "(&(member=CN=Lance Robinson,CN=Users,DC=JUNGLE... ......

Posted On Friday, August 3, 2007 12:51 PM | Comments (1)

LDAP - Search for Group Members

More with the ldap cmdlets in NetCmdlets, here's how to list the members of a particular group. I used the get-ldap command shown in the last post to get a list of all my admin groups, and save it in a $groups collection: PS C:\> $groups = get-ldap -server myserver -cred $mycred -dn dc=JUNGLE -searchscope wholesubtree -search "(&(objectclass=group)(... PS C:\> $groups Host DN ---- -- testboy CN=Administrators,CN=Builti... testboy CN=Schema Admins,CN=Users,DC=JUNGLE testboy ......

Posted On Thursday, August 2, 2007 9:31 AM | Comments (3)

LDAP - Search for Active Directory Groups in PowerShell

NetCmdlets doesn't have a long list of Active Directory cmdlets for PowerShell. Instead, it has 2. And they aren't AD specific - they just implement the LDAP protocol itself so they can work with any LDAP server, Active Directory or not. Two cmdlets are all that is needed to make common tasks simple. One for setting values (set-ldap), and one for getting values (get-ldap). Here's how I can retrieve a list of all the "admin" groups: PS C:\> get-ldap -server myserver -cred $mycred -dn dc=JUNGLE ......

Posted On Wednesday, August 1, 2007 10:28 AM | Comments (0)

Secure, Personal RSS Feeds

I was reading an old post on Scott Hanselman's blog about accessing private feeds via RSS. The discussion turned toward comparing RSS reader requests to OFX requests that applications like Microsoft Money make to banks. A comment from "Jordan": No CTO wants to have his face on the cover of the Wall Street Journal because his site provided an RSS feed to Bloglines and Bloglines has a security breach that exposes all that information. I have several private RSS feeds that I would not trust a third ......

Posted On Thursday, June 14, 2007 12:32 PM | Comments (0)

Impressions from TechEd 2007

Dale Churchward is impressed by NetCmdlets, which he found after David Aiken posted about the NetCmdlets stickers being given away at TechEd. Harry Pierson liked the PowerShell skinned XBox that /n software had at the NetCmdlets booth. Did you get your PowerShell sticker yet and enter the drawing for the XBox? If not, do it now! Jeffrey Snover keeps on doing "snoopy dances" about PowerShell. Who can blame him ......

Posted On Friday, June 8, 2007 3:44 PM | Comments (1)

PowerShell Secure Remoting

You have to love this awesome introduction to NetCmdlets: My previous, scathing, blood-drawing, bruise-inflaming, vein-popping critique of the lack of SSH awareness in the Port25 show has lead my hate-filled, black heart to NetCmdlets by nsoftware.com. Just hilarious. Hopefully NetCmdlets lightened his heart a bit. Also, as I mentioned in the last post, note that /n software's new PowerShell Remoting (beta) was just made available. The PowerShell Remoting server (SSH terminal service) allows interaction ......

Posted On Wednesday, June 6, 2007 1:08 PM | Comments (0)

PowerShelling from mobile devices

Marco Shaw is PowerShelling from his blackberry by running /n software's new PowerShell Remoting server along with the "Mobile SSH" client application for wireless handhelds . You can connect to the PowerShell Remoting client using any SSH tool, or even create your own custom client using a developer tool like IP*Works! S/Shell development toolkit. Technorati : Netcmdlets, PowerShell, nsoftware, ssh ......

Posted On Wednesday, June 6, 2007 12:58 PM | Comments (0)

Managing IMAP access control permissions from Windows PowerShell

Setting access control lists on IMAP servers is a pain. But here's how you can do it very easily with the get/set-imap cmdlets included in NetCmdlets. Retrieve the access control list of my Inbox from the IMAP server, by specifying the -acl flag parameter: PS C:\> get-imap -server 1.2.3.4 -user lance -password mypass -acl Mailbox Rights User ------- ------ ---- Inbox lrswipcda lance PS C:\> Now the access control list for a specific folder: PS C:\> get-imap -server 1.2.3.4 -user lance -password ......

Posted On Thursday, May 31, 2007 5:06 PM | Comments (0)

NetCmdlets Command Line Emailer saves ME time

Scott Hanselman has a little TODO batch file that he uses to quickly email himself notes from the command line. I have something similar, but mine is a PowerShell script that uses NetCmdlets. The cool thing about the send-email cmdlet in NetCmdlets is that it supports SSL as well as other email features like html mail and attachments. There are separate cmdlets for sending other types of messages like Usenet newsgroup articles, Jabber IMs (ie, Google Talk), SMS messages, SNMP traps, etc. Here is ......

Posted On Wednesday, February 28, 2007 9:04 AM | Comments (0)

PowerShell cmdlet for SNMP (part 2: sysUpTime)

Brandon updated his get-uptime script to output a custom object. Brandon's script works with the LastBootUpTime property returned from WMI Win32_OperatingSytem. I already talked briefly about the get-snmp, set-snmp, get-trap, and send-trap cmdlets that are included in NetCmdlets. Here's how you can use get-snmp to get the sysUpTime from any SNMP-enabled device. Note: sysUpTime is defined as the time since the last re-initialization (ie, boot) of the device, in 100ths of a second. get-snmp -agent ......

Posted On Tuesday, February 27, 2007 3:26 PM | Comments (4)

PowerShell book

Bruce Payette's Windows Powershell in Action is now available on Amazon ......

Posted On Tuesday, February 27, 2007 11:46 AM | Comments (0)

Using PSCredentials without a prompt

You cannot use get-credential without some type of prompt (although you can do it without the pop-up dialog), however you can save your securestring password to a file, reload it for later, and manually create a credential without a prompt. Of course the problem with this is that your password will be exposed to anyone with access to the file, so do this at your own risk. First, choose your password and write it to a file: PS C:\> read-host -assecurestring | convertfrom-securestring | out-file ......

Posted On Friday, February 16, 2007 1:21 PM | Comments (12)

No Windows PowerShell Snap-ins are available for version 1

You'll get the error "No Windows PowerShell Snap-ins are available for version 1" if there are no snapins installed for PowerShell v1. But the tricky part is that more precisely you'll get this error if there are no snapins installed for v1 for the platform you're running on. So you'll get this error if you are in a 32bit powershell console and you try to call add-pssnapin on some snapin that builds or installs itself only for x64 (like the Exchange Management Snap-in). You'll get the same if the ......

Posted On Tuesday, January 30, 2007 5:06 PM | Comments (0)

PowerShell and NNTP

Recently Marco Shaw posted a little nntp-stats script in the microsoft.public.windows.po... newsgroup that I thought was pretty neato, and right up my alley since we were in the middle of adding get-nntp and send-nntp cmdlets to the /n software NetCmdlets product. So as a tip of the hat to Marco, here is my version. Poster Stats: Get-nntp returns a collection of objects containing the subject, articleid, sender, references, etc of articles posted in a particular newsgroup. I put together a few ......

Posted On Wednesday, January 24, 2007 5:56 PM | Comments (0)

PowerShell remote exec and secure shell

This is not a post about .Net remoting. And its not a post about accessing PowerShell through ssh. Here I'm talking about sending remote executions through rexec, rshell, and secure shell connections. Rexec and Rshell (rsh.exe) already exist as command line applications, but they do not exists in the PowerShell world (that is, they do not return objects). NetCmdlets send-rexec and send-rshell cmdlets take care of this problem. Each remote execution returns a collection of objects that contain the ......

Posted On Wednesday, January 24, 2007 1:46 PM | Comments (3)

PowerShell console buffer to html

Adrian at soapyfrog posted a function recently for grabbing the contents of the PowerShell console buffer and pushing them out as html. I saved it and finally got around to using it today. Very useful, added to my profile. Thanks Adrian! PS C:\> (get-nntp -server msnews.microsoft.com -newsgroup microsoft.public.windows.po... -list 5) | sort From Number : 7804 Subject : Re: More.com?? Quirk From : "/\\/\\o\\/\\/ [MVP]" Date : Tue, 23 Jan 2007 19:53:16 +0100 Size : 2610 References : <9eo6r256msnc3cvm527hm62... ......

Posted On Tuesday, January 23, 2007 2:19 PM | Comments (3)

Change Active Directory password with NetCmdlets

Here's how you can change your active directory (or other ldap server) password with the set-ldap cmdlet in /n software NetCmdlets. Also, recently I also showed how to this using the IP*Works! SSL LdapS dev component. PS C:\> set-ldap -server myserver -binddn Domain\Administrator -password admin -dn "cn=BillyBob,ou=Employees,d... -newpassword mynewpassword -ssl implicit Update: the -password parameter is now a secure string. There is also a -credential parameter. So the cmd to change the ......

Posted On Wednesday, December 27, 2006 1:33 PM | Comments (0)

NetCmdlets support PSCredentials

Previously with NetCmdlets, authentication details were only accepted using plain text parameters. This is still supported, but now these cmdlets support PSCredentials through a new -credentials parameter. This works for almost all of the cmdlets included in NetCmdlets, like FTP, LDAP, HTTP, SMTP, Rexec, RSS, IM, SMS, SSH, etc. Here's an example with get-ldap. Before, you had to bind to the directory server using plain text parameters, like this: PS C:\> get-ldap -server testboy -binddn mydomain\admin ......

Posted On Wednesday, December 27, 2006 1:27 PM | Comments (0)

NetCmdlets Part 3: PowerShell and Active Directory using /n software's LDAP cmdlet

MOW's "PowerShelled" blog is another awesome PowerShell resource. Of particular interest to me was MOWs series on PowerShell and Active Directory. He used the .Net System.DirectoryServices classes to do all the work. here is how you can use /n software's LDAP cmdlet to manage directory servers like AD. The LDAP cmdlet supports plain connections as well as secure SSL connections. The LDAP cmdlet will work with any directory server, including AD, ADAM, OpenLDAP, Novell, etc. The LDAP cmdlet uses its ......

Posted On Wednesday, December 27, 2006 1:25 PM | Comments (1)

NetCmdlets FTP - recursive directory upload

update: here's an updated function for uploading an entire directory tree: ## ftprecursiveupload.ps1: Recursive FTP Upload## Uploads a directory tree to a remote FTP server.## Returns an objects containing information about the files transferred.function upload-directory { param( [string] $server = $( Throw "You must specify an FTP server to logon to."), [string] $dir = $( Throw "You must specify a local directory to upload (ie, C:\Testing\FTPTest\)"), [switch] $overwrite = $false, [System.Management.Automati... ......

Posted On Thursday, December 7, 2006 11:37 AM | Comments (2)

Vivek's out-ie and out-html scripts, Netcmdlets convert-data cmdlet

I found Vivek Sharma's blog through Jeffrey Snover on the MS PowerShell blog. He's got some good geeky stuff there, including some useful PowerShell posts. Vivek's out-ie is useful, so I snagged that for myself. I tried to create an out-ff but I hit a stumbling block because the Mozilla ActiveX Control requires a control container. out-html is not so useful because convertto-html already comes with powershell. NetCmdlets now includes a convert-data cmdlet which converts data to and from many different ......

Posted On Wednesday, November 29, 2006 2:59 PM | Comments (1)

How to change your active directory password

Last year I posted the rules about how to remotely change your LDAP password. Its not very obvious because of the fact that the procedure depends on what server you're using (Active Directory, OpenLDAP, Novell, etc), and even then how your server is configured. Here is how you would change your password using the LDAPS component of IP*Works!! SSL (note, an SSL connection is required in order to change your password remotely if you are an Active Directory user. Otherwise you can do this with the LDAP ......

Posted On Tuesday, November 28, 2006 3:19 PM | Comments (2)

PowerShell 1.0 Released

PowerShell 1.0 was released yesterday in Spain, and /n software was there! When you go to download it (for free), don't forget to pickup NetCmdlets too. Also check out Jeffrey Snover's 12 Cool Features of Windows PowerShell. You'll need to uninstall previous versions of PowerShell before you can install the new one, but PowerShell won't appear in Add/Remove Programs unless you check the "show updates" box. Technorati : cmdlets, netcmdlets, powershell ......

Posted On Wednesday, November 15, 2006 10:34 AM | Comments (2)

PowerShell verb list

Here is a list of PowerShell cmdlet verbs on MSDN. Technorati : PowerShell, powerShell verbs ......

Posted On Friday, November 10, 2006 2:34 PM | Comments (0)

NetCmdlets Part 2: PowerShell cmdlet for SNMP (network management)

The SNMP PowerShell cmdlets that come with /n software NetCmdlets support SNMP v1, v2c, and v3, SNMPv3 auth/priv, MIB loading, etc. Here are some examples of using the Get-SNMP, Set-SNMP, Send-Trap, and Get-Trap cmdlets. Find SNMP enabled machines (agents) on your network:PS C:\> get-snmp -agent 255.255.255.255 -oid sysName.0 Find processes running on a remote snmp-enabled machine:PS C:\> get-snmp -agent myagent -oid hrSWRunName -walk $true Send an SNMP trap to a remote manager:PS C:\> send-trap ......

Posted On Thursday, November 9, 2006 12:10 PM | Comments (2)

NetCmdlets Part 1: PowerShell cmdlet for FTP (plus FTPS and SFTP)

Some examples of using NetCmdlets in PowerShell. The FTP NetCmdlet supports plain and secure (both SSL and SSH) FTP connections right from the PowerShell console. List files on a remote server: PS C:\> get-ftp -server myserver -user lancer -password mypass The same, but using SSL (auth-tls): PS C:\> get-ftp -server myserver -user lancer -password mypass -ssl explicit And again, but using SSH 2.0: PS C:\> get-ftp -server myserver -user lancer -password mypass -ssh Find the files on a remote ......

Posted On Thursday, November 9, 2006 11:37 AM | Comments (12)

Powershell scripting contest

Windows PowerShell Scripting Sweepstakes. I think its kinda funny, though, that the first prize teaser in the description of the contest is two "all-expenses paid trips to Redmond, WA to meet the Windows PowerShell team". You know I'm sure I would enjoy meeting you all and everything...but I'd rather just have the Xbox. Unless I can get the xbox AND the trip to Redmond. :) Submit your entry scripts in one (or all) of 12 categories: Active Directory SQL Databases IIS 6.0/7.0 Networking Partner Category: ......

Posted On Monday, November 6, 2006 1:41 PM | Comments (0)

Windows Power Shell Quick Start

Here's the Windows Power Shell Quick Start at Channel 9. This is a nice little quick resource for anyone interested in playing with the PowerShell scripting language.

Posted On Wednesday, November 1, 2006 9:18 AM | Comments (0)

About Lance

My resume Email me here Technologies I am interested in and like to play with at work and in my spare time: Software development - mainly C#, but in the past I've worked with VB.NET/VB6/ASP/DelphiPowerS... Blogging, TwitterI am the author of one of the first podcasting applications available (PPR) and the first to be integrated with a media player and offer bookmarking. Note that it has been out of development since iTunes entered the market. I am the author of TextBox1, a site offering ......

Posted On Wednesday, June 8, 2005 8:46 PM

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski