Help using Get-ADgroup

Hello.....How can I get this to except my "GroupName" in the second example?
Example 1. This Works
$Results = Get-ADgroup -LDAPFilter "(name=My_Group_Name)" | Select-Object -ExpandProperty "Name"
$Results
Example 2. This doesn't
$GroupName = "My_Group_Name"
$Results = Get-ADgroup -LDAPFilter "(name=$GroupName)" | Select-Object -ExpandProperty "Name"
$Results
Example 3. works but too slow
$Results = get-adgroup -Filter 'GroupCategory -eq "Security" -and GroupScope -eq "Global"' '
| Where-Object {$_.Name -eq "My_Group_Name"}
| Get-ADGroupMember | select name -ExpandProperty "Name"
The quickest search method in my environment is to use the -LDAPFilter  instead of  -Filter
Thank you

Hi Hecktor,
Example two works just fine for me. Does it throw any errors or is it just a null return?
Example three is of course extremely slow. First you retrieve all global security groups and only after you have them all do you start filtering out those you do not want. You really want to put the name property into the filter ...
Cheers,
Fred
There's no place like 127.0.0.1

Similar Messages

  • Using Get-ADGroup Member recursively across multiple domains in a Forest

    Quick question for the gurus around here....
    We are using a script that is querying the Local Administrators group on a Server.   It will pull the Users as well as the Groups that are a member of the Local Admins group on a server/system and using the recursive parameter with Get-ADGroupMembers,
     it will also list the members of any groups.  However, we seem to hit a snag when a Group is a member of another domain or even if the group is a member of the parent domain/forest.
    For example...One of the Members of the Local Admin group on a server is the "Enterprise Admins".  This group lives in "Corp.Fabrikam.com" yet the server is one level deeper in "ChildDomain.Corp.Fabrikam.com". 
    So of course, when looking in the Child Domain there is no Enterprise Admins group for it to find and it gives us an error that it can not be found.  Samething for Groups that live in other child domains of the forest (ChildDomain2.corp.Fabrikam.com)
    I am trying to figure out how to get the command to distinguish between these differences of the Group accounts and return the results from the domain those accounts live in.   Any ideas if this is normal behavior or if there is a work around?
    Thanks!

    You have to chase the answer.  If you do not have permissions on those domains you cannot retrieve the info.  I suspect it is your script that is wrong and not AD because AD tends to work as required.
    In other words.  Without a script we cannot be of much help.
    ¯\_(ツ)_/¯

  • Get-adgroup get-adgroupmember properties

    Looking to combine 2 commands for csv output.
    For every mail enabled group I need to pull Name, Members, Memberof, whencreated, Info, managedby
    This gets the data but I want memberof and members in a format that an auditor can use.
    get-adgroup -Filter {Proxyaddresses -Like "*"} -properties * | ft Name, Members, Memberof, whencreated, Modified, Managedby, info
    how can I get the members and memberof in a  first name last name format for members and a display name format for memberof?
    Thanks much

    Hi,
    Use a calculated property:
    Get-ADGroup -Filter "ProxyAddresses -like '*'" -Properties Members,MemberOf,WhenCreated,Modified,ManagedBy,info |
    Select Name,
    @{N='Members';E={ ($_.Members | % { (Get-ADUser $_).Name } | Sort) -join ', ' }},
    @{N='MemberOf';E={ ($_.MemberOf | % { (Get-ADGroup $_ -Properties DisplayName).DisplayName } | Sort ) -join ', ' }},
    WhenCreated,
    @{N='ManagedBy';E={ $_.ManagedBy | % { (Get-ADUser $_).Name } }},
    Info |
    Sort -Property Name |
    Export-Csv .\groupInformation.csv -NoTypeInformation
    This uses the Name property for the group members, you can adjust that if needed.
    http://technet.microsoft.com/en-us/library/ff730948.aspx
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • I am in the process of trying to transfer my iTunes library from one computer to another. Some of the music/film info has been edited (by me) in my library (using get info). When put onto new computer the info has gone back to before i edited it.. Help!?

    I am in the process of trying to transfer my iTunes library from one computer to another. Some of the music/film info has been edited (by me) in my library (using get info). When put onto new computer (following apple's instructions- using an external hard drive) the info has gone back to how it was before i edited it.. Help!?

    Hello,
    I would recommend taking a look at the article below for more information about migrating your iTunes library.
    iTunes for Windows: Moving your iTunes Media folder
    http://support.apple.com/kb/ht1364
    -Griff W.

  • HT5538 i can't find the facetime on my iphone i was using it before 1 month after that it's just disappear i need your help to get it back . thank you

    hello everyone i need your help please
    i can't find the facetime on my iphone i was using it before 1 month after that it's just disappear i need your help to get it back .
    thank you

    FACETIME MISSING
    The governments in some middle eastern countries have banned Facetime and it is disabled on iphones purchased in those countries.  The countries include KAS, UAE and others.  There is no way to get Facetime on such phones (for example it cannot be downloaded and installed) and taking the phone to another country does not cause Facetime to reappear on such phones. In  support.apple.com/kb/ts3367  it says “Note: FaceTime may not be available, or may become unavailable, on devices purchased or used in certain countries, including Saudi Arabia and the United Arab Emirates. Check your device's region of purchase for more information.”

  • I am using Vodafone at Delhi India with my Iphone 5S, 3g is activated with my number but i am not getting 3G signals iphone is also activated with vodafone but still waiting for 3G signals contacted vodafone but wasted my time pls help using APN www

    I am using Vodafone at Delhi India with my Iphone 5S, 3g is activated with my number but i am not getting 3G signals iphone is also activated with vodafone but still waiting for 3G signals contacted vodafone but wasted my time pls help using APN www

    Keep on talking to Vodafone and keep pestering them until you get a satisfactory answer.  Whether you get a 3G signal or not, is entirely the responsibility of Vodafone India because they are your carrier/phone company and nobody here can help you with that on a public user to user technical support forum.
    Contact Vodafone as they are the only ones who can help you.

  • Need help to retrieve the message from MQ using get operation

    Hi
    Used MQ adapter to Post a message to queue.
    And used Received activity in bpel to retrieve the message using MQ adapter from same queue(used get operation) , got an error message as timed
    out exception.
    Could some one assist in retrieving the message from MQ using get operation.
    Regards
    Raja

    Hi Raja,
    Is the process a empty bpel process which is used to get the message from the MQ?
    Regards
    Surya

  • How to do a Get-ADGroup and pass SamAccountName with spaces

    Hi,
    I read a text file of groups in SamAccountName form into a variable, then do a Get-ADgroup to ensure they are in a specific SearchBase, then I want to delete them if found in the Searchbase.  Problem is the SamAccountNames have spaces in them
    and I cant figure out the right syntax in the Get-ADGroup for the $Group variable to accomodate the spaces, or put quotes around the $Group variable.  Examples of SamAccountNames are Accounts Payable and LDW URP 
    $EGroups = Get-Content c:\MyGroups.txt
    [int]$counter = 0
    Foreach ($Group in $EGroups) {
    Try {
    $counter++
    $DMGroup = Get-ADGroup -Filter {SamAccountName -eq $Group} -SearchBase "OU=Test,DC=Acme,DC=Com" -SearchScope Subtree
    Remove-ADGroup $DMGroup -Whatif
    $Group | Out-File $env:HOMEPATH\EGroupsRemoved.txt -Append
    Catch {
    $Group | Out-File $env:HOMEPATH\EGroupsNotRemoved.txt -Append
    Write-Host "Processed $counter Groups"
    Thanks for your help! SdeDot

    If you're using the SamAccountName then I would recommend you use the parameter set that allows you to provide it to the -Identity parameter, not the -Filter parameter. You can see the three parameter sets if you do a Get-Help Get-ADGroup and look in the
    Syntax section. The example below will read in groups listed in a text file, even if there are spaces in the groups, and return information about each of them as they pass through the Get-ADGroup cmdlet. You'll definitely want to keep your try-catch blocks
    in place to help gracefully handle any issues where a group cannot be found in the directory.
    Example Text File
    ADMIN-Front Office Staff
    ADMIN-Front Office Students
    $Groups = Get-Content -Path 'C:\GroupFile.txt'
    Foreach ($Group in $Groups) {
    Get-ADGroup -Identity $Group

  • Exchange 2013 CU5 , Exchange Power Shell very very very slow reasponse when using get command.

    Exchange 2013 CU5 , Exchange Power Shell very very very slow reasponse when using get command.
    First my organize has Exchange on 2 site like
    site A (internet facing) : 2CAS 2 MB all are Services pack1
    site B (DR Site , no user active on this site) : 2CAS 2MB all are Services pack 1
    so today I upgrade Exchange 2013 from SP1 to CU5 start on "site B" and I found this issue and the details is....
    When I open EMS on any CU5 for query something (like get-mailboxdatabasecopystatus) the response return very slow and some query will not return at all (like get-owavirtualdirectory).
    But If I using EMS on SP1. Everything is ok then I try to use EMS on SP1 connect to CU5 and try to query something. the result is
    some query command cannot return for any result that are server on siteB (just some query command)
    Problem
    EMS on CU5 return very slow result.
    EMS on SP1 still ok.
    Does anyone face this problem before for CU5??? Please help me figure this out. Thank you
    reply from Social.technet

    Hi,
    Have you used the above cmdlets to check your Exchange server health?
    "all other command that I ran on EMS didn't logged on event viewer.", my environment is the same with you. I use Exchange 2013, only errors will be displayed in MSExchange Management. Actually, it is not related to slow EMS response.
    Hope it helps.
    Best regards,
    Amy Wang
    TechNet Community Support

  • Hi need help on getting customer open  items

    hi all,
    i need help regarding getting open items for customers in the previous
    ie. if i give current date,
    i want to get the open items for past 30 days from current date
    help me to get this ...
    thanks a lot
    regards,
    selvi

    or else ,
    use table BSID.
    Regards
    Peram

  • Help using scanner class to count chars in file

    Hi all, I am learning Java right now and ran into a problem. I need to use the Scanner class to accurately count the number of chars in a file including the line feed chars 10&13.
    This what I have and it currently reports a 201 byte file as having 194 chars:
         File file = new File(plainFile);
         Scanner inputFile = new Scanner(file);
         numberOfChars = 0;
         String line;
         //count characters in file
         while (inputFile.hasNextLine())
              line = inputFile.nextLine();
              numberOfChars += line.length();
    I know there are other ways using BufferedReader, etc but I have to use Scanner class to do this.
    Thanks in advance!

    raichle wrote:
    Wow guys, thanks for the help! I've got a RTFMWell, what's wrong to have a look at the API docs for the Scanner class?
    and directions that go against the specs I said.Is that so strange to suggest a better option? What if I ask a carpenter "how do I build a table with a my stapler?". Should I give the man an attitude if he tells me I'd better use a saw and hammer?
    I'm also aware that it "eats" those chars and obviously looking for a way around that.
    I've looked through the java docs, but as I said, I'm new to this and they're difficult to understand. The class I am auditing req's that this be done using Scanner, but I don't see why you demand an explanation.
    Can anybody give me some constructive help?Get lost?

  • Hi apple user. I have lost all iPad safari bookmarks. Tried hold home button with sleep button but it doesn't get back my safari bookmarks. I also have reset without erasing my iPad data but still doesn't work. Help me get back my safari iPad bookmarks.

    Hi, I have lost all iPad safari bookmarks. Have tried reset without erasing data and hold home and sleep button together but when go to safari all safari bookmarks still lost. Is there any case help me get back my iPad safari bookmarks ? Currently my safari is hanged, can't surf webs or anything. I saw the safari tab on iCloud is on, but I don't know using iCloud. Please help me get back my iPad safari bookmarks. I have contact Apple but could not set chat session. I have my Apple ID registered same with iCloud, also same during the time I have all iPad safari bookmarks lost. My iPad never synced on computer since I bought it with set at local store. Please help me get my iPad safari bookmarks back, thanks.

    Hi, I quitted Safari and press and hold the Home and Sleep buttons silmutaneously unti the Ipad turn off and on with the logo Apple appears but it has hanged on and fixed to the point. I do it again hold the Home and Sleep buttons silmutaneously and the Ipad turn off and on again with the Apple logo but it still is hanged on the same point. I have do it a few more time, it still hanged to the same point for few hours with no change (like picture):
    I think my Ipad is fault now. I guess I must connect it to the computer with itune, or something. So my case is this: at the moment everytime I hold the Home and Sleep buttons the Ipad always off and reappear with the Apple logo and be hanged on (like the pic), and I need restoring my Ipad Safari bookmarks... so I guess I need using Itune or something to get back the Ipad then using Icloud or blah. Please guide me for the step, Im not sure if connect to PC, if any that my Ipad data would lost, or is there anyway that I also can get back Ipad Safari Bookmarks after connecting to PC, also the how using Icloud. There is no Apple store or service store in my country so I think I must do it my self. Feel free to share your guide, thanks.

  • How do I use Get-ADUser to get just the Managers attribute? And then get rid of duplicates in my array/hash table?

    Hello,
          I am trying to just get the Managers of my users in Active Directory. I have gotten it down to the user and their manager, but I don't need the user. Here is my code so far:
    Get-ADUser-filter*-searchbase"OU=REDACTED,
    OU=Enterprise Users, DC=REDACTED, DC=REDACTED"-PropertiesManager|SelectName,@{N='Manager';E={(Get-ADUser$_.Manager).Name}}
    |export-csvc:\managers.csv-append 
    Also, I need to get rid of the duplicate values in my hash table. I tried playing around with -sort unique, but couldn't find a place it would work. Any help would be awesome.
    Thanks,
    Matt

    I would caution that, although it is not likely, managers can also be contact, group, or computer objects. If this is possible in your situation, use Get-ADObject in place of Get-ADUser inside the curly braces.
    Also, if you only want users that have a manager assigned, you can use -LDAPFilter "(manager=*)" in the first Get-ADUser.
    Finally, if you want all users that have been assigned the manager for at least one user, you can use:
    Get-ADUser
    -LDAPFilter "(directReports=*)" |
    Select @{N='Manager';E={ (Get-ADUser
    $_.sAMAccountName).Name }}
    -Unique | Sort Manager |
    Export-Csv .\managerList.csv -NoTypeInformation
    This works because when you assign the manager attribute of a user, this assigns the user to the directReports attribute of the manager. The directReports atttribute is multi-valued (an array in essence).
    Again, if managers can be groups or some other class of object (not likely), then use Get-ADObect throughout and identify by distinguishedName instead of sAMAccountName (since contacts don't have sAMAccountName).
    Richard Mueller - MVP Directory Services

  • Is there any "mechanical" helper to get my volume levels the same?

    I create playlists from ratings,(and comments),- and albums have different volume levels. As I always use my ipod to go to sleep, it is very destructive, to not be able to hear my music one minute, and then have it much too loud the next.
    Is there ANYTHING, free or chargeable, physical or software, that can help me get my itunes library to all the same volume level. My problem is agrivated by the fact that I do have some shared downloads, and also someone put my vynils onto cd for me, but at a lower volume.
    I might add, that I'm still a learner on the computer. I have been told to change the soundcheck -playback -preferences -itunes. I have tried it, ticked and unticked - it doesn't make any difference.
    I'd be very gratefull for some advice. Please HELP, this has been going on for ages. Thank you, in anticipation.

    I'm SO very grateful for your help! Have downloaded it, and have started to use it, but havn't listened to results yet.(just about to) THANKYOU SO MUCH.
    Thankyou so much again, this could be the end of a long (negative) era!
    A bit later: have listened to a little, seems a huge amount better. will update when used properley.
    I'm anticipating some being way out. Though it says it can overcome old changed volume levels, is it best in your opinion, to put them back to original setting?
    Many Best Wishes Vonnie

  • Can someone help me get my web address bar back up on Safari?

    I don't really know what you call it, but the bar that you type web addresses in, at the top of the page, somehow disappeared. If I use this browser it is only to visit pages that I had bookmarked, because I have no way of typing in new addresses. I'm not really sure what I did, but it's gone...
    I have Safari 2.0.4, but I just don't see anything in Preferences or anywhere else that will help me get bar back on the page. Can someone help me?

    lol that was easy... I had been over that but apparently didn't drag it over to the bar correctly last time I was in there.
    Thanks

Maybe you are looking for