Get-aduser compare attributes inside the -filter parameter

Hello all,
What I would like to do is use the -filter parameter of get-aduser to compare 2 attributes within the search itself, instead of having to process the differences afterwards.
So here is how I normally use -filter:
get-aduser -filter {(name -like "*") -and (displayname -like "*")} -Properties displayname | `
Foreach-object{
If($_.name -eq $_.displayname){
"Match!"
As you can see, I have to get all the users and their properties first, and then subsequently I have to use a ForEach-Object loop to determine if there are any matches.
What I would like to do is do the comparison in the -filter parameter. Something like this:
get-aduser -filter {name -eq displayname}
However, I'm not aware of any way to compare attributes within -filter, and I wonder if anyone knows of a way? Or is a subsequent loop the only way to compare?

Hi,
You can use -and in the filter:
Get-ADUser -Filter "SamAccountName -eq 'smithr' -and GivenName -eq 'Robert'"
I'm not exactly sure if this is what you're asking about though.
EDIT: I think I know what you're asking now. AFAIK, there is no way to use -Filter to return users who have the same DisplayName attribute as their Name attribute. You need to have something concrete to test against inside of the filter.
Don't retire TechNet! -
(Don't give up yet - 12,950+ strong and growing)

Similar Messages

  • Getting JPA class attributes inside Visual JSFs

    Hi,
    I'm new her, so I'm deeply sorry if I'm writing this on the wrong place. But I have a small issue with the Visual JFSs in Netbeans.
    I have created a project where a person can log in and see some data, all is done using Java persistence API. I was able to get the JPA attributes into a normal JSP. by doing something like this.
    <body>
            <f:view>
                <h1><h:outputText value="You are now logged in" /></h1>
                Welcome ${user.email}  You've been loggedin successfully.
                <h:form>
                    <h:commandButton id="logout" value="Logout" action="#{usermanager.logout}"/>
                </h:form>
            </f:view>
        </body>it works fine and displays the correct result. But when I go and do this inside a Visual JSF, it does NOT give me any compiler errors. But it wont display anything. Just a blank screen. If I remove that particular code and put some label or text there, then it works. But NOT when I try to access the JPA attributes.
    Why is this happening?. I basically need a way to retrieve the bean information which is stored in a Entity class which was created from the database. Can't I do it using this ${user.email} kind of notation. If so, then how to do it. Can someone please help me.
    Thanks a lot.

    Source is empty, But I checked the app server log after you suggested. It says something like this (among other things).
    Caused by: javax.servlet.jsp.JspException: Can't write content above <f:view> tag Illegal to flush within a custom tag
    so I tried out something like this.
    <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <f:view>
            <webuijsf:page id="page1">
                <webuijsf:html id="html1">
                    <webuijsf:head id="head1">
                        <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
                    </webuijsf:head>
                    <webuijsf:body id="body1" style="-rave-layout: grid">
                        <webuijsf:form id="form1">
                            <webuijsf:label binding="#{user.email}" id="label1" style="position: absolute; left: 120px; top: 72px" text="Label"/>
                        </webuijsf:form>
                    </webuijsf:body>
                </webuijsf:html>
            </webuijsf:page>
        </f:view>
    </jsp:root>but still it doesn't work. There was a conversion error where #{user.email} returns a String but it could not be assigned to a label. so I tried it this way as well.
    <webuijsf:body id="body1" style="-rave-layout: grid">
                        <webuijsf:form id="form1">
                            <webuijsf:staticText id="staticText1" binding="#{user.email}" style="position: absolute; left: 72px; top: 72px"/>
                        </webuijsf:form>
                    </webuijsf:body> Now there were no errors, But still it doesn't work.
    I ONLY need a way to get the information inside the entity classes which was created from the database using Object Relational Mapping. My problem is this works fine inside regular JSP but not inside Visual JSF. ??? :(

  • All of a sudden, when I'm cropping an image in Photoshop CS6, I get a spiral curl inside the image while I'm resizing it. I've never had this before and it's a bit annoying. How do I get rid of it?

    I've been using Photoshop CS6 for a few years and have done tons of cropping but never before have I had this spiral curl inside the image.  How do I get rid of it and get back to the normal resizing/cropping of an image?

    Verify your settings in the options bar.

  • How to get currently running tcode inside the user exist

    Hi All,
    I want to write user exist for me22n & me23n, inside the user exist i want to check tcode whether tcode is me22n or me23n my user exist is ME_PROCESS_PO_CUST
    .please help me
    Thnx//

    Hello Gevan,
    Please check the value of sy-tcode for both transaction in debugging mode in the exit and write your code accordingly.
    case sy-tcode.
    when 'ME22N'
    *ur code
    When 'ME23N'
    *ur logic
    endcase.
    find the screen shot from debugging
    Thanks

  • Any Chance of Getting 8x10 Crop Overlay inside the 8x12?

    Hello,
    I am using 2.3 and have not downloaded 2.4 but am wondering about a possible overlay feature.
    Most cameras shoot an 8x12 frame yet I am often cropping for the lowest common denominator - 8x10.
    Since some of the overlays resize inside the crop box, I am wondering why there is not a choice to add 8x10 or 5x7 ratios?
    I am often delivering a digital file that is in 8x12 but needs to be "safe" for 8x10.
    I have written this in the new features section but it strikes me as odd that Lightroom has a squiggly resizing shape and not photo frame sizes marked!
    This great program has revolutionized my workflow and this one feature would stop a lot of guessing when cropping, making the program even better.

    Other than keeping on developing your eye to know when you've got a safe crop in this situation, you could, as a workaround:
    crop a batch to your normal ratio, then go through them quickly with the crop tool  set to 8 x 10, apply it, check then hit escape and move on.
    Alternatively, you could create a batch of Virtual Copies, rename them, perhaps adding '8x10' to the file name, and crop them to the 8 x 10.
    Finally, if you so wish, you could add this as a feature request.

  • Problem getting from a custom Worklistapplikation the Modifiable Parameter

    Hi Guys.
    Task task2 = querySvc.getTaskDetailsById(context, task.getSystemAttributes().getTaskId());
    AnyType anytype = task2.getPayload();
    List list = anytype.getContent();
    for(int l = 0; l < list.size(); l++) {
    Element part = (Element)list.get(l);
    System.out.println(part.getFirstChild().getNodeValue());
    Know i want to know, how do i get any parameter to know if this is editable (created in the Human Task) or not?
    Mys best regards

    Hi,
    Are you still watching this topic? I am having a similar problem... But I'm not sure its because of number of rows deleted... I have n rows in my table and I delete all rows, but yes, the delete happens one row at a time, so maybe it matches your scneario. Then I do a getSelectedRowCount, which returns 1, but getRowCount returns 0!!!!
    This should definitely be reported as a bug!!!
    Shefali

  • How to get rid of dust inside the screen of an ipad mini?

    MY ipad mini has a dust inside of it. Any tips to get rid of it?

    I would recommend you to show your iPad to an Apple Store Genius

  • Using get-aduser -filter to find blank spaces only

    Hello all,
    What I'm trying to do is pretty simple. I want to use the -filter parameter of the get-aduser cmdlet to find a defined attribute that only contains a space. For example, I want to find any users that have extensionattribute1 equal to " ". I've
    tried the following code but I get the error "the search filter cannot be recognized":
    get-aduser -filter {extensionattribute1 -eq " "}
    What I don't want to use is -like "* *", as that will give me values that contain a space anywhere. I only want to return users that have extensionattribute1 equal to one space.
    Any ideas?

    Yes, in LDAP syntax you can escape any character with the backslash escape character followed by the two character hex ASCII representation of what you want. You can get foreign characters this way. More on escaping characters here:
    http://social.technet.microsoft.com/wiki/contents/articles/5312.active-directory-characters-to-escape.aspx
    Richard Mueller - MVP Directory Services

  • Get-ADUser : The server has returned the following error: invalid enumeration context.

    I'm running a powershell command to add the email (AD mail) attribute to users in a specific OU.  It seems to work then will bomb out with the error in the title.
    I'm using a "scripting guy" command that I've altered with my specfic OU/domain information however, I'm pasting in the more "generic" version :: Get-ADUser -LDAPFilter "(!(mail=\.name*))" -resultSetSize $null -searchbase "ou=test,dc=nwtraders,dc=com"|
    % {set-aduser -identity $_.distinguishedname -email ($_.samaccountname + "@nwtraders.com")}
    I work for a school district and this command is being used to add the mail attribute to the student's accounts.  I think about 2/3 of the students are completed but the script/command bombs and I'm not sure where or why.  I've resubmitted the
    command several times but I'm not sure whether it's starting from where it bombed or if it's starting again at the beginning and essentially re-doing the ones already completed.
    Can someone point me in the direction of a work around or a resolution to the Get-ADUser error?
    Thanks!!

    I don't know the error, so I can only guess there. But the LDAP syntax filter cannot be correct. Can you provide a link to the reference where "Scripting Guy" suggested this?
    As written, you are retrieving all users where the mail attribute does not begin with the string ".name" (case insensitve), where "name" is not a property or attribute, but a string value. LDAP syntax clauses are in the format:
    (<attributeName><operator><value>)
    In your case, <operator> is "=", <attributeName> is "mail", and <value> is ".name". The "\" character is the escape character, which means to interpret the following character (the period in
    this case) literally. You cannot use an attribute name on the right side of the operator (the "="), unless PowerShell has introduced some functionality I am not familiar with to expand the LDAP syntax. For example, the following does not filter
    on users where the first name is the same as the last name:
    (givenName=\.sn)
    Instead, it filters on users where the first name is the string ".sn". Even if "\.name" was interpreted by the Get-ADUser cmdlet to be the "Name" attribute of the user, this would cause problems. "Name" is the
    Relative Distinguished Name of the user (the value of the cn attribute) and it could include commas or spaces. I would expect "\.sAMAccountName" to make more sense.
    Richard Mueller - MVP Directory Services

  • Unable to read blob attributes in the Asset Filter

    Hi,
    I am unable to read a blob attribute in the Asset Filter using the following code.
    The String attributes work fine.
    Can I get some examples for reading blob attributes in the filter?
    I am using Webcenter Sites 11gr1
    public void filterAsset(IFilterEnvironment env, String filterIdentifier, FTValList filterArguments, IFilterableAssetInstance instance) throws AssetException
    String inputattr = getAttrID(env, filterArguments, ARG_CUSTOM[0]);
    IListBasic ilistbasic = instance.getAttribute(inputattr);
    ilistbasic.getValue("value") // throws No such field exception.. works fine for string attribues
    Thanks,
    Raj

    Hi
    In DTP, Filter there is option to write routine. The last button.
    Here u can write the below code :
    Select <fields> from table into itab.
    Read itab into wa_itab where <condition>.
    If sy_subrc = 0.
         l_t_range-FIELDNAME = ' '. <give ur field name in source>
          l_t_range-sign = 'I'.
          l_t_range-option = 'EQ'.
          l_t_range-low = wa_itab-field.
        APPEND L_T_RANGE.
    endif.

  • Powershell get-aduser filter problem

    Powershell'Filter' = {(Enabled -eq $True) -and ((Office -ne "EXCLUDE") -or (Office -notlike '*'))}
    The filter parameter isn't very user friendly.  Try this and see if it is what you want.

    Hello all, I am trying to filter a script I found here from Martin9700to get users from an ad ou. The original line: 'Filter' = {Enabled -eq $True} works and I am trying to add a filter to exclude users that have Office value of EXCLUDE. If I use: 'Filter' = {(Enabled -eq $True) -and (office -eq "EXCLUDE")} then it will get the user that has EXCLUDE but I can't get any negative to work. I have tried -ne, -notlike and several combos of syntax but I really don't understand much of it. Any help would be greatly appreciated! The complete script is below. Thanks!

  • PSE11 CIB11 How do I get the filter menu under Graphic & Favorite to work?

    Why does the filter menu in the bar below the sorting menu does not show up for "By Word"-paper/travel in the search box.  But it shows up for "By Color"
    How to I get to work in "Graphic" the filter menu?

    Please post Photoshop Elements related queries over at
    http://forums.adobe.com/community/photoshop_elements

  • Get-ADUser SamAccount from CSV file does not work.

    So I'm trying to get HomeDirectory + SamAccountName using Get-ADUser from an imported csv file called $csvFile
    $GetUserInfo = Get-ADUser (Get-ADUser -Filter { displayName -eq $csvFile[$index].DisplayName}).SamAccountName -Properties SamAccountName,HomeDirectory
    It gives me an error. 
    Get-ADUser : Invalid type 'System.Object[]'.
    Parameter name: displayName
    At line:1 char:28
    + $GetInfoUser = Get-ADUser (Get-ADUser -Filter { displayName -eq $csvFile[5].Disp ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Get-ADUser], ArgumentException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Commands.GetADUser
    However if I do like this 
    $DisplayName = $csvFile[$index].DisplayName
    and replace $DisplayName to the filter like this, it works flawless and I get HomeDirectory and the SamAccountName
    (Get-ADUser -Filter { displayName -eq $DisplayName }).SamA...
    Any ideas or improvements

    Still produces the same error. I'm running 4.0
    How about this?
    Import-Csv C:\Temp\user.csv | % {
    $displayname = $_.displayname;
    get-aduser -filter { displayname -eq $displayname } | Select SamAccountname , HomeDirectory
    The below was my CSV format
    DisplayName
    Chendrayan Venkatesan
    Ramesh Venkatesan
    Regards Chen V [MCTS SharePoint 2010]

  • Get-Aduser Filtering Issue

    Hey Guys,
    I'm trying to do a get-aduser filter based on two criteria 
    1. the account is enabled
    2. the samaccountname does not contain the word health
    I'm stumped on this one. Here's what i have thus far. I have to be close
    Get-ADuser -Filter 'enabled -eq $true' -and 'SamAccountName -ne "Health*"'
    Thoughts ? This is driving me crazy.
    Rich
    Rich Thompson

    Hi,
    afaik the -Filter-parameter only applies to AD-properties. enabled is a powershell-AD-object property. It is represented by the UserAccountControl flag in the ActiveDirectory (see description
    here) and you'l combine it with the SAMAccountName, similiar to something like this:
    Get-ADUser -filter {((userAccountControl -like "512") -and (samaccountname -notlike "Health*"))}
    Regards
    Sebastian
    You can filter on the Enabled property with no issues. Also, just FYI, -Filter wants a string, not a scriptblock. Scriptblocks will generally work, but not always.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Get-aduser filters

    My organization has a lot of users, including limited-use accounts and service accounts. Sometimes I just want to perform a query on "real" users which have a specific format:
    1) all "real" users start with the letter "s"
    2) they all have a 5 digit number after the "s"
    3) they all end with an "n" or a "d"
    How would I do a get-aduser to return just the "real" users in my organization? Do I need some sort of regex, or can I use get-aduser -filter 'samaccountname -like xxxxx' ?
    Thank you
    [email protected]

    I don't think you'd need a loop, at the worst, a where-object piped after:
    $users = get-aduser -filter * | Where-Object {$_.samaccountname -match "[Ss]{1}[0-9]{5}[NnDd]{1}"}
    [email protected]
    Don't discount the provider filter just because it won't filter exactly what you want:
    Get-ADUser -Filter {SamAccountName -like 's*'} |
    where { ($_.SamAccountName -match "[Ss]{1}[0-9]{5}[NnDd]{1}") }
    will eliminate all the accounts that don't start with "s" up front, cutting down on what's left to filter in Where-Object.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

Maybe you are looking for

  • IC Webclient - Changing values in Text Type -Log in view IRecReason.htm

    Hi, I m working on IRecReason.htm view, in the right hand side corner there is a place to add comments, the field is named as text types. All comments are then stored & visible in the Field named as "LOG" which is also one of the valus in the drop do

  • Palm Z22 Handheld and iSync - compatible?

    Is the Palm Z22 Handheld compatible with iSync 2.1.1? It is sold online in the Apple Store but is not listed on the iSync compatible list on the Apple web site, nor does Palm list it as compatible except with PCs - via MS Outlook. Seems like it must

  • Joining bridge ,dim,fact table

    Hi I have scenario where I have a bridge table,dimension table,and 2 fact tables. The dimension table is a common table for both fact tables. The bridge table contains the dimension tables Primary key. The bridge is also having an other dimension tab

  • Dumps in sap pi

    Hi Gurus, Can any body tell me that on what cases we will get Dumps in sap pi ,Can any body share me is there any documents related to dumps. It is very help ful for me . Thanks&Regards

  • Photoshop CS6 Scaling issues: Vector/Raster smart objects

    My team and I have noticed some strange issues when affecting the overall interpolation of a .psd via scaling, cropping, or canvas resize. Test: Original .psd is even x even overall pixel dimensions. Original vector and raster smart object assets are