Close Menu
    Facebook X (Twitter) Instagram
    Trending
    • Successful Adoption of a “Cloud First” Strategy
    • Speaking at Nordic Virtual Summit
    • Workplace Ninja User Group Denmark February Meetup
    • Workplace Ninja User Group Denmark Meetup – May 2022
    • Workplace Ninja User Group Denmark Meetup – April 2022
    • Speaking at Modern Endpoint Management Summit 2022
    • Speaking at Nordic Virtual Summit 2022 – 3nd Edition
    • CoLabora Recordings – January 2022
    RONNIPEDERSEN.COM
    • Home
    • Enterprise Mobility
      • Configuration Manager
      • Identity and Access
      • Information Protection
      • Intune
    • Cloud and Data Center
      • Data Center Management
      • Group Policy
      • Enterprise Security
      • Hyper-V
      • PowerShell
    • Guides
    • Webcasts
    • Links
    • About
      • Contact me
      • Disclaimer
    RONNIPEDERSEN.COM
    You are at:Home»Cloud and Data Center»PowerShell is King! Find misconfigured users in AD

    PowerShell is King! Find misconfigured users in AD

    0
    By Ronni Pedersen on March 21, 2017 Cloud and Data Center, Identity and Access, PowerShell, Windows Server

    Today I got a call from a customer that was working on a Office 365 Project. As part of the Project they wanted to change the Exchange Email Address Policies to filter on the Company Name for each user. Only problem was that some of the users had a blank or misspelled Company name…

    Luckily, someone invented PowerShell so we started by pulling a list of all Company Names by running this command:

    Get-ADUser -Filter * -Properties Company | Group Company | Select Name,Count

    SNAGHTML13b8fb8d

    The result was as expected… Too many company names. Misspelled Company Names and users with no company name specified at all…

    SNAGHTML13bcd7b5

    To get a list of all users with a “blank” Company Name; Run the following command:

    Get-ADUser -Filter * -Properties Company | Where {$_.Company -match “^$”} | Select samaccountname

    SNAGHTML13c3806c

    The result included a lot of service accounts and other stuff where the Company Name might not be super important. But we did find +100 accounts that needs a Company Name.

    SNAGHTML13c91773

    Changing the company names can of course be done by PowerShell too, but in this scenario we didn’t have any luck to automate the assignment of the different company names, but the overview helped them a lot…

    /Enjoy
    +Ronni Pedersen

    • Tweet
    • Share 0
    • +1
    • LinkedIn 0

    Related

    Ronni Pedersen
    • Website
    • Facebook
    • X (Twitter)
    • LinkedIn

    My name is Ronni Pedersen and I'm currently working as a Cloud Architect at APENTO in Denmark. My primary focus is Enterprise Client Management solutions, based on technologies like AzureAD, Intune, EMS and System Center Configuration Manager. I'm is also a Microsoft Certified Trainer and Microsoft MVP in Enterprise Mobility.

    Related Posts

    Workplace Ninja User Group Denmark February Meetup

    CoLabora Recordings – December 2021

    CoLabora User Group Meeting – December 2021

    Leave A Reply Cancel Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Follow
    APENTO

    Follow APENTO here:

    Subscribe to Blog via Email

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    About
    My name i s Ronni Pedersen and I'm currently working as a Cloud Architect at APENTO in Denmark. My primary focus is Endpoint Management and Security, based on Microsoft technologies. I'm also a Microsoft Certified Trainer and a dual Microsoft MVP in both Security and Windows.
    Recent Posts
    • Successful Adoption of a “Cloud First” Strategy
    • Speaking at Nordic Virtual Summit
    • Workplace Ninja User Group Denmark February Meetup
    • Workplace Ninja User Group Denmark Meetup – May 2022
    • Workplace Ninja User Group Denmark Meetup – April 2022
    Archives
    TOP POSTS
    • How to Access the MBAM BitLocker Recover Keys directly in SQL
    • Windows Vista Pre-Build VHD available for download
    • Find the TimeZoneName for your SCCM/MDT Deployments
    • SCCM: Enable Desktop Clients as PXE Servers
    • Windows 10 1803: winpeshl.ini file is present, but no commands were successfully launched
    RECENT COMMENTS
    • Sebi on Prepare for Co-Management: Migrate Intune Devices without user affinity
    • Vadim P on SCCM: Failed to Get Client Identity (80004005)
    • TM on Active Directory Based Activation in an multi domain environment
    • unkown on Setting OSDComputerName using CustomSettings.ini
    • TJ Scott on Setting OSDComputerName using CustomSettings.ini
    DISCLAIMER
    The content on this website is presented "as-is" with no guarantees. The use of scripts from this website is at your own risk. Always test before putting something in production! Opinions expressed are my own.
    © 2025 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.