header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Piping values to a filter parameter
Last Post 07 Jun 2010 06:29 AM by MrMcGregor. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Resolved
MrMcGregorUser is Offline
New Member
New Member
Posts:8
Avatar

--
04 Jun 2010 08:46 AM

    Hello,
    I'm trying to use PowerShell to take a list of names in a .csv file and populate custom attributes with them. The process I'm using is to import the csv content to a variable, and then pipe that to some commands, like the following.

    $stuff = import-csv "c:\filename.csv"
    $stuff | % -process{
    $data = $_.column1 `
    get-mailcontact -filter {displayname -like "*/some kind of variable etc.." }| `
    set-mailcontact -customattribute1 "$data"
    }

    The problem I run into is that I'm trying to search for mail contacts using the last portion of their displaynames. An example displayname is like the following.

    Big Conference Room/North Carolina/RTT

    I'm searching for this contact with a filter of {displayname -like "*/RTT"}.
    I can search this way if I do it one at a time, but when I'm trying to do it in bulk, I'm having trouble passing a value to the filter that represents */RTT that will work correctly.

    Any help on this would be great!!

    Andrew

    Vishal RamnaniUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    07 Jun 2010 01:09 AM
    Try adding one more variable before the filtering command as below.

    $Filter = "*" + $YourVariable

    get-mailcontact -filter {displayname -like $Filter}| `
    set-mailcontact -customattribute1 "$data"

    Hope this helps.

    Thanks
    Vishal Ramnani
    MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
    MrMcGregorUser is Offline
    New Member
    New Member
    Posts:8
    Avatar

    --
    07 Jun 2010 06:29 AM
    Vishal,

    Thanks for the information. That worked perfectly. I built the syntax essentially as a string associated with a variable as you said.

    $Filter = "*/" + "$data"

    Then just used $Filter in the "like" statement.

    Works as I wished it would.

    Thank you very much for the instruction.

    Andrew
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer