Thanks Tony. It's not pretty but it works. :) $PlantItems | Select-Object ` @{Name="Category";Expression={$_["Category"].Substring($_["Category"].IndexOf("#")+1)}}, @{Name="Plant Item";Expression={$_["Title"]}}, @{Name="Code";Expression={$_["Code"]}}, @{Name="Rego#";Expression={$_["RegoNo"]}}, @{Name="Expires";Expression={$_["RegoExpiry"]}}, Description | Sort-Object Category,Code
Regards, Paul From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Tony McGee Sent: Thursday, 27 March 2014 7:58 PM To: ozMOSS Subject: Re: Powershell - sort list by lookup field You could sort by an expression: (Generate some test data...) PS> $n = 1; $testData = "#Banana","#Orange","#Apple" |% { New-Object PsObject -Property @{Identifier=('{0};{1}' -f $n++,$_)} } PS> $testData | Sort-Object -Property Identifier Identifier ---------- 1;#Banana 2;#Orange 3;#Apple PS> $testData | Sort-Object @{Expression={$_.Identifier.Substring($_.Identifier.IndexOf(';'))}} Identifier ---------- 3;#Apple 1;#Banana 2;#Orange Alternatively: PS> $testData | Sort-Object @{Expression={ ($_.Identifier -split ';')[1] }} Cheers, Tony On 27/03/2014 14:11, Paul Noone wrote: Hi all, I'm trying to sort a SharePoint list by lookup field value. I've tried the pipeline and also SPQuery and both are returning the ID and value pair - e.g. 17;#My Value - so the sort is based on the ID and not the field value. Is there an easy way around this? Regards, Paul The content of this email is confidential to the intended recipient at the email address to which it has been addressed. It may not be disclosed to, or used by, anyone other than this addressee, nor may it be copied in any way. If received in error, please contact the author and then delete the message from your system. Please note that neither Keller Australia nor the sender accepts any responsibility for viruses and it is your responsibility to scan the email and attachments (if any). Visit http://www.keller.com.au/ for more information. ________________________________ This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal ________________________________ _______________________________________________ Sponsored by Infotext - Amazing Search for Microsoft SharePoint - http://www.infotext.com/ ozmoss mailing list ozmoss@ozmoss.com<mailto:ozmoss@ozmoss.com> http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss The content of this email is confidential to the intended recipient at the email address to which it has been addressed. It may not be disclosed to, or used by, anyone other than this addressee, nor may it be copied in any way. If received in error, please contact the author and then delete the message from your system. Please note that neither Keller Australia nor the sender accepts any responsibility for viruses and it is your responsibility to scan the email and attachments (if any). Visit http://www.keller.com.au/ for more information. -------------------------------------------------------------------------------- This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal --------------------------------------------------------------------------------
_______________________________________________ Sponsored by Infotext - Amazing Search for Microsoft SharePoint - http://www.infotext.com/ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss