Get-AdUser and a other domain

I'm having problems running a script to search all accounts on a Domain.
I want to be able to switch domain choices
Current script is:
Import-Module activedirectory
Get-ADUser -Filter * -Properties * |
Select-Object Name,LastLogonDate | export-csv C:\users.csv -notypeinformation
I've tried the following to no avail - still outputs my domain not the selected:
import-module activedirectory
$data =@()
$domains = "another.domain.com"
foreach($domain in $domains)
 $data += Get-ADUser -Filter * -Properties * | Select-Object Name,LastLogonDate
$data | export-csv C:\users.csv -notypeinformation
Any ideas?

Hi ESXi,
I’m writing to just check in to see
if the suggestions were helpful. If you need further help, please feel free to reply this post directly so we will be notified to follow it up.
If you have
any feedback on our support, please click here.
Best Regards,
Anna Wang
TechNet Community Support

Similar Messages

  • Hello. I am trying to change the colors on my ical. I have been able to select a calendar group, click "get info" and then "other" in the color options and which point a a lot of color options are available. HOWEVER, I can't seem to select the color.

    Hello. I am trying to change the colors on my ical. I have been able to select a calendar group, click "get info" and then "other" in the color options and which point a a lot of color options are available. HOWEVER, I can't seem to select the color. I click on a new color and press enter and nothing happens...not sure what I am doing wrong.

    What do you currently see?
    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Do you have the menu bar?
    *Press the F10 key or tap the Alt key to bring up the hidden Menu bar.
    Do you have any toolbars visible at all?
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Make sure that you do not run Firefox in full screen mode (press F11 or Fn + F11 to toggle; Mac: Command+Shift+F).
    *https://support.mozilla.org/kb/how-to-use-full-screen
    You can check for problems caused by a corrupted localstore.rdf file.
    *http://kb.mozillazine.org/Corrupt_localstore.rdf

  • Having upgraded iOS7 on both my iPad and iPhone yesterday, I am now not able to use my FaceTime on either device. I seem to get through and the other party can hear me but I can see nor hear nothing.

    Having upgraded iOS7 on both my iPad and iPhone yesterday, I am now not able to use my FaceTime on either device. I seem to get through and the other party can hear me but I can see nor hear nothing.

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime: Set-up, Use, and Troubleshooting Problems
    http://tinyurl.com/32drz3d
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
     Cheers, Tom

  • Get-ADUser and Get-ADPrincipalGroupMembership combined

    I'm trying to get a list of template user account and what their membership are exported to a csv file. I'm trying to combine the tables on them but having a hard time figuring it out. I spent the day racking my brain on this and figured I would reach out
    for help. This gets all my template users.
    Import-Module ActiveDirectory
    $User = "*Template*"
    $usernames = (Get-ADUser -Filter "DisplayName -like '*$User*'" -Properties * | format-table Displayname, SamAccountName)
    $usernames
    I can use this to get all the members of the groups, but since the groups repeat it doesnt break down where one user stops and the others begin. 
    $groups = Get-ADUser -Filter "SamAccountName -like '*$Usr*'" -Properties DisplayName | foreach-object{Get-ADPrincipalGroupMembership -Identity $_.SamAccountName} | format-table name
    I was thinking of joining the tables but that wasnt much help to me since I cant figure out what to join on. I also thought about looping through the first table with a foreach loop but it was assigning the whole table in the first pass and displaying nothing.
    If anyone could help or suggest something, I would greatly appreciate.
    Matt

    Hi Matt,
    Give this a shot:
    Get-ADUser -Filter "DisplayName -like '*Template*'" -Properties MemberOf | ForEach {
    $username = $_.SamAccountName
    $_.MemberOf | ForEach {
    $props = @{
    Username = $username
    GroupName = (Get-ADGroup $_).Name
    New-Object PsObject -Property $props
    } | Sort Username,GroupName |
    Select Username,GroupName |
    Export-Csv .\GroupMemberships.csv -NoTypeInformation
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • Get-ADuser and formatting results

    What Im looking to do is to output all of my AD Users, including all of their properties, and then output that to a tabular format. The issue I am having is that some of the fields, like MemberOf, dont come through. My script looks like the following:
    Get-ADuser -Filter * -Properties * | Export-CSV C:\Temp\MyFile.csv
    This is almost what I want, but I just need for all of the properties to be expanded. Some end in "..." meaning there is more to be shown, and others such as "MemberOf" show "Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" instead of showing
    the actual groups.
    Thanks in advance for any help!
    Jarrod Sturdivant [email protected]

    I had the same question and the "Exchange Proxy Address (alias) Report" Blog entry helped me a lot in this case.
    Here is my adaption
    $multipcgroups = @()
     $Pclist = import-csv mypclist.csv | foreach {get-adcomputer -identity $_.name -Properties * | select name, memberof}
     foreach ($pc in $pclist) {
     [array]$pcgroups = $pc.memberof
    $ErrorActionPreference = 'SilentlyContinue'
     $pcadgroup = New-Object PSObject -Property @{
    Name = $pc.name
     pcadgroup0 = $pcgroups[0] -replace "OU=SW,OU=Groupx,OU=foo,DC=company,DC=de" -replace "OU=Filter,OU=Technical Roles,DC=company,DC=de"
    pcadgroup1 = $pcgroups[1] -replace "OU=SW,OU=Groupx,OU=foo,DC=company,DC=de" -replace "OU=Filter,OU=Technical Roles,DC=company,DC=de"
    pcadgroup2 = $pcgroups[2] -replace "OU=SW,OU=Groupx,OU=foo,DC=company,DC=de" -replace "OU=Filter,OU=Technical Roles,DC=company,DC=de"
    $ErrorActionPreference = 'Continue'
     $pcadgroupCount = ($pcgroups).count
     if ($pcadgroupCount -gt 0) {
    $multipcgroups += $pcadgroup
     $multipcgroups | select name, pcadgroup0,pcadgroup1,pcadgroup2 | Export-CSV pcadgroups.csv -notype
    regards
    Andreas

  • How do I run Get-ADUser and filter out two separate OUs

    Ha! I was assuming that Where-Object wouldn't do me any better. Well, I guess I made an ass out of me. ;)
    Your first script is what I will use. We have some user accounts in other OUs that are disabled for other reasons.
    It's little quirks like this that keep me from using Powershell more often.
    Thanks Matt!

    Hi again all!I am trying to write a script that will search for AD users that have the "Password Never Expires" box checked, but not if they are in one of two OUs. These OUs are not parent/child, they are separate.If I run this, I get about 30 results:
    Powershellget-aduser -filter { PasswordNeverExpires -eq $true }Some of the results are in the "Disabled Accounts" OU, some are in the "Contractors" OU, and the rest are in neither.
    If I run either of these, I get zero results:
    Powershellget-aduser -filter { PasswordNeverExpires -eq $true -and DistinguishedName -notlike "*Disabled*"}get-aduser -filter { PasswordNeverExpires -eq $true -and ( DistinguishedName -notlike "*Disabled*" -and DistinguishedName -notlike "*Contractors*")}I know for a fact that I have users that are not in either of these two OUs that have that box checked because I...
    This topic first appeared in the Spiceworks Community

  • Migrating from 2003 domain/forest level to 2008R2 with all DC's at 2008R2 and 2 other Domain External and Forest Trusts

    Is there anything that needs to be done or considered when migrating from 2003 domain/forest level to 2008R2 with all DC's at 2008R2 with 2 other 2003 separate Domain incoming
    and outgoing Trusts, one Trust that is a Forest Trust and the other is an External Trust? Is there any chance or risks that doing this upgrade will break either one of these Trust relationships? Some of the user accounts with SID history have been migrated
    from both Domain Trusts to our domain. Any chance that this upgrade will break these relationships for users that are using SID history for access to folders and files in their old Domains? If so what can be done to protect these trusts and SID history, prior
    to moving the Domain to 2008R2

    Hi,   
    Based on my knowledge,
    the Upgrade of the function level do not affect the trust relationship.
    Besides, before you upgrade the Functional Level,
    verify that all DCs in the domain are, at a minimum, at the OS version to which you will raise the functional level.
    Once the Functional Level has been upgraded, new DCs on running on downlevel versions of Windows Server cannot be added to the domain or forest.
    For more information about function level, we can refer to following links:
    Understanding Active Directory Domain Services (AD DS) Functional Levels
    http://technet.microsoft.com/en-us/library/understanding-active-directory-functional-levels(v=ws.10).aspx
    What is the Impact of Upgrading the Domain or Forest Functional Level?
    http://blogs.technet.com/b/askds/archive/2011/06/14/what-is-the-impact-of-upgrading-the-domain-or-forest-functional-level.aspx
    Best Regards,
    Erin

  • How to get help and help others on the Spotify Community!

    So I thought I would make this informal, light-hearted post about how to help other and get help on the community :)
    A Community is About Mutual Relations
    This means that people help you, so that you help them. You share your newly gained knowledge, so others can benefit. You get help, and then you help others by replying to their topics.
    It Always Pays to be Polite
    People will want to help you more if you are polite, with no swearing or hate speech. We all get annoyed from time to time, and some get annoyed more than others. We understand that the product you're paying for isn't working, but screaming, shouting and swearing about it won't help. Be polite, and help will come.
    Always Pack as Much Information in as Possible
    Often I am trying to help others, and there is just not enough info posted for me to help them well. This slows down the support they can get, which makes them further annoyed. To solve this issue post as much info as you possibly can:
    Any error messages
    A description of what is happening
    What have you tried to do to fix it
    What happened when you tried to fix it
    Oh, a screenshot always helps ;)
    Don't Post Personal Info
    Almost every day I have to report a post for containing an email address, telephone number and sometimes even the users home address. Apart from being against the community guidelines, this is rather stupid. These forums are public, and any person, bot, stalker or alien entity can see it. So just don't post them - it would save everyone's time ;)
    Payment Issue? Don't come to us ;)
    Payment issues cannot be dealt with on the community, unfortunately, as we don't have access to your Spotify account or details. You should use the Support Form to contact the customer services team, and they will get back to you (eventually).
    Post in the correct section!
    I am forever moving posts over to the correct sections. Please - post in the correct section to begin with. If you need help, post in the help forums, and post in the relevant help forum. You will get a quicker response if you post in the right section ;)
    Post in the Correct Thread
    Most common issues already have a thread, but people don't seem to be able to see them. If you have deleted a playlist post in the deleted playlist thread!
    Make Sure you Accept a Solution!
    I don't really like having to accept a solution for others, as I don't know for sure whether or not it was actually the solution, but the OP of the thread doesn't do it - so who is?
    Give Kudos!
    Kudos is like a pat on the back. Everyone gets a nice feeling when they gain a kudo. Please kudo regularly - they cost nothing and mean everything ;)
    I think that's it...
    If I have forgotten anything don't be afraid to send me a private message about it!

    cluelessjoe wrote:
    I WANT TO KNOW IF I PAY FOR THE 10 DOLLAR SERVICE, CAN I DOWNLOAD MY PALYLISTS ..I HAVE OVER 11,000 SONGS ALMOST 11,500 SONGS .. WILL MY LAP TOP CRASH AFTER I DOWNLOAD THEM FOR PLAY OFFLINE ..I DO HAVE A BACKUP DISK ..... THANK U SO VERY MUCH ..I DIG SPOTIFY .. I AM NOT INTO LOSING ALL MY SONGS OR HAVING MY LAP TOP CRASH .. THANKS   CLUELESSJOE !!
    Hey! Welcome to the community :) 
    If you have 11,000 songs in a Spotify playlist (not as local files you own) you won't be able to mark them all to be available offline, since Spotify limits each device to 3,333 offline stored tracks due to licensing restrictions. 
    Peter

  • Only some of my edited info gets published, and not others?!?!

    I built a website for my mom on iweb about 8 months ago. I make changes to it monthly and have no problem publishing the changes.
    However; today I made some changes to the site on iweb today, and the changes I made to the contact page, and product pictures page. But the changes I made on my home page and about us page will not publish no matter how many times I do it. Its so frustrating, the only changes I made was to the words, deleted some words, added some new ones, made some spaces between lines and they just wont stick.
    I save it, then publish it to a folder, then I use CuteFTP Mac to publish, which I've never had a problem with.
    PLEASE HELP, I am getting paid to publish these changes and I cant seem to do it!
    Thanks in advance,
    Garcy

    Hi,
    my guess is that the changes get published but you don't see them.
    If a change doesn't display to you in the browser after you published and uploaded it mostly is because the old version of the page is cached (memorized) by your browser. Thus simply emptying the cache of the browser (Open Safari, choose Safari from the menu and go to Empty Cache) and reloading the page should display the changes.
    Regards,
    Cédric

  • Two 3G Phones ... One is Getting WiFi and The Other Isn't ... What Gives?

    I am trying to connect a 3G phone to WiFi. When I try with one iPhone 3G, I enter in the password, it connects and then provides service and the connection works properly. I then try doing the same thing with another 3G phone and it appears to connect to that network and then indicates "No Service." Any ideas

    Are there any charges?
    No.
    What if I'm not on wifi? Is it still free?
    Yes.
    Exchanging iMessages is similar to exchanging emaill - an internet connection is required via an available wi-fi network or cellular data or internet network.

  • Why does firefox sometimes just stop talking to the internet and just set there with the connection icon spinning and spinning and not going anywhere, when Thunderbird can still get email and any other program is not having trouble accessing the internet

    sometimes fire fox will start talking again, most of the time it take a reboot to fix it, as it may set there spinning, for hours, and i do not have time to fool with it, and a reboot is a pain

    Hi,
    Do you have this problem with the ethernet and wireless connection ?
    Did you installed any windows updated on your Windows 8.1 ?
    A+
    HK.
    Hicham KADIRI | Just Another IT Guy

  • Use Get-ADUser to get locked status and if locke give a choice to unlock it.

    Hi guys and girls,
    Im startling to learn powershell scripting and have made my first tool/Script.
    Below script is the one i use, however i do have an problem i would like some help with.
    I use the script to display some basic info and also to show if the user is lockedout or not.
    However i do would like to have the choice to unlock the user in the script as well, therefore im using the if statement.
    But dont get it to return the value i want. What i want it to do is to check if the account is locked if so ask if it should unlock it. Any help or input is appreciated.
    /Json
    $userinput = Read-Host "Enter Username Here"
    Get-ADUser -Identity $userinput -Properties * | Select-Object DisplayName, city, department, EmailAddress, HomeDirectory, MobilePhone, OfficePhone, Manager, PasswordExpired, PasswordLastSet, LockedOut
      If(((Get-ADUser -Identity $userinput -Properties lockedout).lockedout = $true))

    Hi there, I've not tested this properly but it should do the trick.
    add-type -AssemblyName System.DirectoryServices.AccountManagement
    $userinput = Read-Host "Enter Username Here"
    $res = Get-ADUser -Identity $userinput -Properties DisplayName, city, department, EmailAddress, HomeDirectory, MobilePhone, OfficePhone, Manager, PasswordExpired, PasswordLastSet, LockedOut | Select-Object DisplayName, city, department, EmailAddress, HomeDirectory,
    MobilePhone, OfficePhone, Manager, PasswordExpired, PasswordLastSet, LockedOut
    if ($res.lockedout -eq $true){
    $unlock = Read-host "Unlock? Y/N"
    if ($unlock -eq "Y")
    $context = [System.DirectoryServices.AccountManagement.ContextType]::Domain
    [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($context,$userinput).UnlockAccount()

  • Using get-aduser to search for enabled users in entire domain filter ..

    Hi,
    my first post here.
    I have the following problem. I am trying to figure out to create a powershell command (with get-aduser) that searches for only enabled
    users (in the entire domain),  whose user account login names starts with "b" or "B" (because their user account login names are composed of Bnnnnn, n=numbers). I suppose that a string of "B*" in the command should be sufficient. The query result
    must show the user account login name (Bnnnnn),  first name
    and last name  and the enabled  (yes) status  of those enabled users. I would like to write the entire query result to a file (csv format), saving it to c: for example
    Please help. Thanks in advance

    I use -LDAPFilter mostly because I am used to the LDAP syntax. It can be used in PowerShell, VBScript, dsquery, VB, and many command line utilities (like Joe Richards' free adfind utility). Active Directory is an LDAP compliant database.
    The PowerShell -Filter syntax can do the same things, but the properties it exposes are really aliases. I'm used to the AD attribute names, like sAMAccountName and userAccountControl. PowerShell uses things like "enabled" and "surname", which are aliases
    you need to know or look up. For example, the Get-ADUser default and extended properties, with the actual AD attributes they are based on, are documented here:
    http://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx
    Finally, note that the "Name" property refers to the Relative Distinguished Name (RDN) of the object, which for user objects is the value of the cn attribute (the Common Name of the user). This may not uniquely identify the user, as it only needs to be unique
    in the parent OU/container. The user login name (pre-Windows 2000 logon name) is the value of the sAMAccountName attribute, which must be unique in the domain. In the Wiki article I linked, we see that the PowerShell alias for this attribute is "SamAccountName"
    (in this case the name of the property matches the name of the AD attribute). All of this can be confusing.
    Richard Mueller - MVP Directory Services

  • How to get Get-AdUser to work with different domains

    Hello,
    I have 3 domains:
    domain.com
    domain.abc.com
    domain.co.nz
    I have this Get-ADUser PowerShell script that works with the first domain listed 
    Get-ADUser -Filter {enabled -eq "true" -and title -like "*"} -SearchBase "DC=domain, DC=com" -Properties hiredate, department 
    But does not work with the other 2.  Not sure how to write the SearchBase parameter.  Can you help?
    Paul

    See these.
    http://social.technet.microsoft.com/forums/windowsserver/en-US/a2b541f6-17cc-492a-a687-38337cafa41e/querying-multiple-subdomains-for-users-with-getaduser
    http://powershell.com/cs/forums/p/11582/19928.aspx
    Regards,
    Biswajit
    MCTS, MCP 2003,MCSA 2003, MCSA:M 2003, CCNA, Enterprise Admin, ITIL F 2011
    Blog:
      Script Gallary:
      LinkedIn:
    Note: Disclaimer: This posting is provided & with no warranties or guarantees and confers no rights..

  • 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

Maybe you are looking for