taartero
asked on
Exchange Powershell question for filtering results of a query
I have a command that gets me the information of a users Safe Senders:
Get-MailboxJunkEmailConfig uration JohnDoe |Select-Object -ExpandProperty trustedsendersanddomains | sort-object
if you run
Get-MailboxJunkEmailConfig uration JohnDoe
the results would have each email address within a parenthesis separated by commas.
If you run 1st command I listed you get the emails in a column. If the user entered specific email addresses like JaneDoe@hotmail.com, you see that in the result.
if they tried to add a Domain to their safesender, the Outlook UI lists it like @Hotmail.com
the powershell command will result showing the Hotmail domain as just Hotmail.com
w/o the @ sign
So, what I am looking for is, the right syntax to get only the addresses that are complete (not the domain entries).
I tried to filter my search by only showing the items that have the @ sign
Get-MailboxJunkEmailConfig uration JohnDoe |Select-Object -ExpandProperty trustedsendersanddomains | ? {$_.trustedsendersanddomai ns -like "*@*"} | sort-object
which does not work. :(
Get-MailboxJunkEmailConfig
if you run
Get-MailboxJunkEmailConfig
the results would have each email address within a parenthesis separated by commas.
If you run 1st command I listed you get the emails in a column. If the user entered specific email addresses like JaneDoe@hotmail.com, you see that in the result.
if they tried to add a Domain to their safesender, the Outlook UI lists it like @Hotmail.com
the powershell command will result showing the Hotmail domain as just Hotmail.com
w/o the @ sign
So, what I am looking for is, the right syntax to get only the addresses that are complete (not the domain entries).
I tried to filter my search by only showing the items that have the @ sign
Get-MailboxJunkEmailConfig
which does not work. :(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so Much!
hopefully you still answer the comment I made
hopefully you still answer the comment I made
It may make more sense to you if you run
property is. At the top of the output you should see the type of the object that is output, like "TypeName: System.String". When you run the code in this post you will see all the properties and methods available for the objects sent to the Get-Member cmdlet (i.e. the objects output by Get-MailboxJunkEmailConfig uration).
Get-Member is very useful when you're developing a script and are trying to discover what information is available to you and what you can do with it.
Get-MailboxJunkEmailConfiguration JohnDoe | gm
(gm is an alias for Get-Member) and compare the results to what you saw earlier. Basically what you saw was the properties and methods available for a string, which is what the "trustedsendersanddomains"Get-Member is very useful when you're developing a script and are trying to discover what information is available to you and what you can do with it.
ASKER
Get-MailboxJunkEmailConfig
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone(), System.Obje
CompareTo Method int CompareTo(System.Object value)
Contains Method bool Contains(string value)
CopyTo Method void CopyTo(int sourceIndex, char[
EndsWith Method bool EndsWith(string value), bool
Equals Method bool Equals(System.Object obj), bo
GetEnumerator Method System.CharEnumerator GetEnumerato
GetHashCode Method int GetHashCode()
GetType Method type GetType()
GetTypeCode Method System.TypeCode GetTypeCode(), Sys
IndexOf Method int IndexOf(char value), int Index
IndexOfAny Method int IndexOfAny(char[] anyOf), int
Insert Method string Insert(int startIndex, stri
IsNormalized Method bool IsNormalized(), bool IsNormal
LastIndexOf Method int LastIndexOf(char value), int L
LastIndexOfAny Method int LastIndexOfAny(char[] anyOf),
Normalize Method string Normalize(), string Normali
PadLeft Method string PadLeft(int totalWidth), st
PadRight Method string PadRight(int totalWidth), s
Remove Method string Remove(int startIndex, int
Replace Method string Replace(char oldChar, char
Split Method string[] Split(Params char[] separ
StartsWith Method bool StartsWith(string value), boo
Substring Method string Substring(int startIndex),
ToBoolean Method bool IConvertible.ToBoolean(Sys
.....
I was looking through those results trying to make sense of what I was reading. I thought as I was going down that list, that I was going to find the "-expandproperty".
After going through that list, I couldn't see what I think you were trying to tell me.
I am still very interested in you explaining what the "get-member' is actually telling me (since im guessing it is getting me the member {properties} of the result)
Anyhow, I then ran your second command:
Get-MailboxJunkEmailConfig
and the answer for me is in the pipe "" ? {$_ -like "*@*"} ""
Where the $_ is left blank... vs. $_.VALUE
Thanks so much, it worked like a CHAMP