Help with the Shell
Hello - I need some help with some commands I am putting together.
I am going to be getting a list of users that need to be migrated to a 2007 org. I first want to verify that the users in the list have a set of matching attributes. Specifically, DisplayName and CustomAtrribute2 are going to match exactly.
This will indicate the account is indeed ready to be migrated.
I tried setting up a foreach loop to go through the file's list of names, and then running a Get-Mailbox. I am having trouble adding a where statement that will allow me to specify something like where Displayname -eq CustomAttribute2
This is an example of what I have run so far:
First I get the content of the file with a $list = Get-Content C:\filname.txt then I run the Foreach loop: Foreach ($i in $list) {get-mailbox $i | fl displayname,customattribute2} | where {"displayname" -eq "customattribute2"}
Does anyone have any suggestions? I am kind of learning this as I go in a test environment but have been spinning my wheels for a bit. When I pipe to the where, I get an error saying "An empty pipe element is not allowed"
Everything works fine right up until the "where"
Thanks
January 18th, 2012 5:14pm
Looks like you've got most of the right bits there, they just need to be arranged a little differently.
$list = Get-Content C:\filname.txt
Foreach ($i in $list) {
get-mailbox $i |
select displayname,customattribute2 |
where {$_.displayname -eq $_.customattribute2} | ft
}
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
January 18th, 2012 5:26pm
Thanks that worked brilliantly.
Funny I had tried something very close to that just messing around yesterday without the select. Reminds me a lot of SQL. I have gotten used to using Format-List to get my attributes and what I needed was to select the attributes.
Excellent thanks so much for the quick response.
Lesson learned, this will help me along greatly.
Ray
January 18th, 2012 5:46pm