Powershell script to Scan Active Directory Attributes for Country and Department ,Then add to Sales Group then add to Distribution list based on Region

Hey Scripting Guys,
I have been in and out of Powershell last few years, not that great at it tbh !!! I'm looking for advice on how I can as in Title, Create a Powershell script to Scan Active Directory Attributes for Country and Department ,Then add to Group then add to Distribution
list based on Region/Country
I was thinking along the lines of get-aduser -LDAPFilter "(department=SALES France) and adding a where clause for country.
Any help would be great.
Dec

So I have tried a few variations but get errors on both 
get-aduser -LDAPFilter "(&(department=SALES)(c=us))" | Add-ADPrincipalGroupMembership -MemberOf "testgroup"
get-aduser -LDAPFilter "(&(department=SALES)(c=fr))" | Add-ADGroupMember -identity "testgroup"
Add-ADPrincipalGroupMembership : Object reference not set to an instance of an
object.
At line:1 char:86
+ get-aduser -LDAPFilter "(&(department=SALES)(c=fr))" | Add-ADPrincipalGroupMe
mbership <<<< -MemberOf "testgroup"
+ CategoryInfo : NotSpecified: (:) [Add-ADPrincipalGroupMembershi
p], NullReferenceException
+ FullyQualifiedErrorId : Object reference not set to an instance of an ob
ject.,Microsoft.ActiveDirectory.Management.Commands.AddADPrincipalGroupMem
bership

Similar Messages

  • SBS 2008 - Microsoft Azure Active Directory Module for Windows PowerShell - is not supported by your version

    Hi,
    I was following the artigle (http://www.messageops.com/resources/office-365-documentation/ad-fs-with-office-365-step-by-step-guide/) but
    when try to install the 'Office 365 PowerShell Module' shows a msg saying that 'windows azure active directory module for windows powershell is not supported by your version'.
    And according to the blog (http://blogs.office.com/2014/04/15/synchronizing-your-directory-with-office-365-is-easy/) "DirSync can be
    installed on an existing domain controller"
    >>>> Any help is appreciated.
    * Similar issue: http://www.adaxes.com/forum/post7398.html

    Ok Vasil tks for reply, but this server is 64x. I dont get the point.
    Microsoft Windows [Version 6.0.6002]
    C:\Users\Administrator>set
    ALLUSERSPROFILE=C:\ProgramData
    APPDATA=C:\Users\Administrator\AppData\Roaming
    CLIENTNAME=ANJOTEC_NOTE01
    CommonProgramFiles=C:\Program Files\Common Files
    CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
    COMPUTERNAME=COMPANYBR-SERVER
    ComSpec=C:\Windows\system32\cmd.exe
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Users\Administrator
    lib=C:\Program Files\SQLXML 4.0\bin\
    LOCALAPPDATA=C:\Users\Administrator\AppData\Local
    LOGONSERVER=\\COMPANYBR-SERVER
    NUMBER_OF_PROCESSORS=4
    OS=Windows_NT
    Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files\HP\NCU;C:\Windows\sys
    em32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\
    1.0\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program File
    (x86)\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Serve
    \90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program F
    les (x86)\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files (x86)\Microsoft SQ
    Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Vis
    al Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\ExchangeMapi\
    C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x
    6)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Rox
    o Shared\9.0\DLLShared\;C:\Program Files\Microsoft\Exchange Server\bin;C:\Progr
    m Files\Microsoft\Exchange Server\Scripts
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    PROCESSOR_ARCHITECTURE=AMD64
    PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 30 Stepping 5, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=1e05
    ProgramData=C:\ProgramData
    ProgramFiles=C:\Program Files
    ProgramFiles(x86)=C:\Program Files (x86)
    PROMPT=$P$G
    PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
    PUBLIC=C:\Users\Public
    RoxioCentral=C:\Program Files (x86)\Common Files\Roxio Shared\9.0\Roxio Central
    3\
    SESSIONNAME=RDP-Tcp#0
    SystemDrive=C:
    SystemRoot=C:\Windows
    TEMP=C:\Users\Administrator\AppData\Local\Temp\2
    TMP=C:\Users\Administrator\AppData\Local\Temp\2
    USERDNSDOMAIN=COMPANYBR.LOCAL
    USERDOMAIN=COMPANYBR
    USERNAME=administrator
    USERPROFILE=C:\Users\Administrator
    windir=C:\Windows
    C:\Users\Administrator>

  • Pre-populate adapter for setting the Active Directory OU for a user

    Hi All
    I created a pre-populate adapter that set the Active Directory OU for a user...
    In the end the status of the resource is still showing "provisioning"..
    It must be "Provsioned"..did I miss something ?
    The logs speak as below :-
    08:01:12,678 INFO [STDOUT] Running Create User
    08:01:12,678 INFO [STDOUT] Before appending Root Context:OU=Human Resources,
    08:01:12,678 INFO [STDOUT] tcUtilLDAPController.java : hierString : OU=Human Resources,dc=mydomain,dc=com
    08:01:13,553 ERROR [ACTIVEDIRECTORYCONTROLLER] Problem creating object: javax.naming.OperationNotSupportedException: [LD
    AP: error code 53 - 0000001F: SvcErr: DSID-031A0FC0, problem 5003 (WILL_NOT_PERFORM), data 0
    ]; remaining name 'cn=ASYMONDS'
    08:03:18,756 INFO [[xlWebApp]] action: LogonAction: User 'XELSYSADM' logged on in session 8116CBC0FA1481D06A207A1941B9
    E096
    08:22:31,256 ERROR [WEBAPP] Class/Method: ProvisionedResourcesForUserAction/confirmEnableSelection encounter some proble
    ms: No checkbox was checked.

    Just verify the OU value is correctly populated , first try doing the provisioning by manually giving OU and everything .
    Is it successful ?
    Then we can check if something wrong going with pre pop.
    Thanks
    Suren

  • Making LDAP calls to update Active directory attributes

    Hi,
    I see a lot of postings about authenticating using LDAP, Ibut I am trying to make LDAP calls to update Active directory attributes
    How can I do this from my BPEL process ? My input xml file will have a list of users whose attributes need to be updated.
    I need to query by making LDAP calls and update as needed.
    I am a novice to a step by step guidance will be very helpful.
    Thanks much!

    This is really an AD question. Basically the easist way is to expose a web service to do this then BPEL calls that web service. I think later versions of AD do this out of the box.
    Otherwise there are many examples on Google using differnt technology.
    cheers
    James

  • Active Directory Attributes

    Can the universe designer read in Active Directory attributes?  I'm trying to apply row-level security to allow members of one group (by department ID, which is stored in an attribute in AD) permission to only view their department's information.  Any help would be greatly appreciated.  Thank you.
    Chris

    Hi Chris,
    You need to have configured AD authentication in the CMC. You can then import the AD group(s) with its users and use the group(s) in the Designer to apply row level restictions.
    Hope this helps
    Jacques

  • Active Directory - Server 2008 R2 and 2012 R2 (Server Formatting or not productive

    Hello guys, I come here to try to clarify a great doubts regarding Server Operating Systems, I will attempt to detail the most of my scenario.
    Suppose I have a Server 2008 R2 in production, and this is my Active Directory server (meudominio.local) and am managing through Group Policy settings my workstations that are around 60-70 computers, guys my doubts the thing is, if I need some time to format
    and perform a fresh installation of my server as it will be my Active Directory? Of course I will have lost my domain controller and I have to accomplish the placement of each workstation again that enters my domain one by one.
    I know there is the option of AD replication, so we call the Active Directory, even for another version of the Operating System, prátia already realized this, but it most often comes not functioning properly, done without replication problems Server 2003 to
    2008 R2.
    Guys like to know a solution to not having to put my plants in my domain network again one by one, is there any way to backup so that when I reinstalled the system and the AD again in my server stations return to "see" again that server as your domain
    controller, even me installing AD with the same domain name before this formatting stations do not respond to this driver in this case do the Network ID or add the station to the area again, so she creates a new user profile for example (Max.meudominio) while
    your old profile "guy" still remains on the machine, I adopted the practice of editing the record of this newly created profile and pointing him well for the old user folder which contains all data and settings, eg edit my key "ProfileImagePath"
    regedit logged in with the newly created profile (Max.meudominio) ->
    (switch "ProfileImagePath" C:\Users\Max.meudominio) thus pointing to the folder before replacing in the field again this season after formatted server, thus ->
    (Switch "ProfileImagePath" C:\Users\Max), detail that we give permission for all such user "C:\Users\Max" folder, after that restart the computer and he comes back with the user profile and all your settings.
    I wonder if there is another method to perform this procedure, do not know even a backup AD to not have to replace all the seasons again "meudominio.local".
    Thank you for your attention!
    Translation with Google translator! Sorry.
    Matias Duarte Coordenador de Suporte Dual Solucoes&#174; | Solu&#231;&#245;es em tecnologia da informa&#231;&#227;o

    As the practice of replication I know her mostly said she has some flaws when I do the replication of my domain to another server but it works correctly, so having a server "master" and the other ServidorBKP as "slave", in redundancy,
    the problem is when I say, and put the "ServidorBKP" being my primary domain controller and disabling my main controller, to disable or turn off my main controller the stations themselves are unable to login because it does not communicate with the
    my ServidorBKP "slave" even I put it as the main driver of course.
    Regarding the System State as far as I know this option existed in Server 2003.
    I also got some information, confer on the links below.
    http://msdn.microsoft.com/en-us/library/bb727048.aspx
    http://technet.microsoft.com/pt-br/library/cc758435(v=ws.10).aspx
    http://technet.microsoft.com/en-us/library/cc961934.aspx
    I'm still researching other ways, getting communicate any news to everyone. (Google Translate)
    Matias Duarte Coordenador de T.I. Dual Solucoes® | Soluções em tecnologia da informação http://www.matiasduarte.com.br

  • Additional attributes for requester and approver

    Hi,
    I have a scenario:
    1.Requester should raise the request to assign the role for beneficiary and requester should select 'Valid from' and 'valid till' (valid from and valid till are additonal attributes)
    2. Approver will reivew the request and should be able to change the 'valid from' and 'valid till' dates ( role active dates )
    I have changed the 'AssignRolesDataset.xml' to display the additionals attributes for approver task by making 'approver-only'.
    Can I add addtionals attributes for requester ? Can the requester additional attributes values will visible to approver to review and change?
    These Additional attributes stores in which table?
    Can any one Please guide me here.
    Thanks
    gr

    Hi,
    I have created the 'AssignRolesDataset.xml' as below and imported successfully in oim (purged also), but not able to see the additonal attributes when I raise the request from self service and select the 'Assign Roles' , also not able to see the attributes with approver.
    AssignRolesDataset.xml
    <request-data-set xmlns="http://www.oracle.com/schema/oim/request" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/schema/oim/request" name="AssignRolesDataset" entity="Role" operation="ASSIGN">
    <DataSetValidator name="CreateUserDataValidator" classname="oracle.iam.requestactions.plugins.datavalidator.CreateUserDataValidator"/>
    <AttributeReference name="RoleActiveFrom" attr-ref="RoleActiveFrom" type="Date" length="30" widget="date" read-only="true"/>
    <AttributeReference name="RoleActiveTo" attr-ref="RoleActiveTo" type="Date" length="30" widget="date" required="true"/>
    </request-data-set>
    Please correct me here.
    Thanks
    Gr

  • Marketing Attributes for account and Contact

    Hi,
    I am looking at Marketing Attributes of an Account. They are fine.
    And I am looking at Marketing attributes of an Contact for this account. But these values are different from Account Marketing Attributes.
    They are not same...can you please let me know..when they will bcome same (for Account and his contact).
    And when I create lead(campaign)...will these attributes changes for Account and Contact?
    Please let me know...as I am very new to CRM Marketing.
    Thanks,
    Sandeep

    Hi,
    If the marketing attribute set is created with assignment to bith Accounts and Contacts.. the same would be visible through out.
    If u want different set of attributes for contacts and accounts, define multiple marketing attributes and select the checkbox for availability in either contacts or accounts and not both.

  • I have activated the genius for Ipad and the message that It was a success never disappears . It is impossible to access the itunes or apple store. What can I do?

    I have activated the genius for Ipad and the message that It was a success never disappears . It is impossible to access the itunes or apple store. What can I do?

    You have encounter Activation Lock, the antitheft feature of the iPhone. The previous owner did not remove the phone from their account. The phone cannot be used until they do. Return to the store and let them sort this out. It is very unusual for someone to "forget" to disable activation lock, as it is necessary to do so to erase personal information on the phone. So it is quite likely you bought a stolen phone.

  • SAP Standard Field Attributes for ME21n and ME

    Hi,
    Can anyone suggest me where i can see all the display,Hidden,Mandatory, optional SAP Standard field attributes for ME21N and ME51N.
    I looking for Configuration settings
    Thanks
    Venki

    Hi ,
    All i see is Field Label                    Reqd.entry  Opt. entry  Display for ME21N and ME51N
    I want to see what SAP Standard Fields are Hidden for these T-codes.
    I want to use and Non Used Field ( Hidden SAP Field) for new Enhancement instead of creating a custom Tab
    Thanks
    Venki

  • Hello I have a iphone that even if enconta in the activation screen asking for email and password of the previous owner

    Hello I have a iphone that even if enconta in the activation screen asking for email and password of the previous owner

    Only the owner of the Apple ID or the original purchaser of the device from a retail store can do anything about that.
    Find My iPhone Activation Lock: Removing a device from a previous ...
    Contact the person from whom you purchased the iPhone for assistance or a refund.

  • Dropdown lists for function and department on BP are sorted by key not desc

    Hi,
    In the new WEB UI the dropdowns for function and department are sorted by the key rather than the description.
    This is causing the users major problems as they usually end up grouped together because of the way they were named.
    Can anyone suggest how i can get the F4 help in the WEB UI for department and function so it is sorted by the description.?
    Thanks
    Matt

    Ok here goes....
    Department:
    UI Component: BP_CONT
    View: BP_CONT/ContactDetails
    Context Node: RELATIONSHIP
    Attribute: STRUCT.DEPARTMENT
    Object Type: BP_CONTACT
    Attribute: <DEFAULT>
    Design Object: BP_CONTACTRELATION
    Function:
    UI Component: BP_CONT
    View: BP_CONT/ContactDetails
    Context Node: RELATIONSHIP
    Attribute: STRUCT.FUNCTION
    Object Type: BP_CONTACT
    Attribute: FUNCTION
    Design Object: BP_CONTACTRELATION
    Hope this gives you enough infoirmation, and thanks for looking into this.
    Thanks
    Matt.

  • Dynamic List for Country and City

    I want to create two drop down list for Country and City. So if the user selects a country from dropdown list the other drop down list should automatically be refreshed tos how its corresponding cities.
    I tried using JCOMBOBOX but there is no method in this class there i can pass the data at run time.
    Can any one pls send me a sample code?
    Thanks

    Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.
    edit
    pinto_g, please post your questions to an appropriate forum in future.
    Edited by: DarrylBurke

  • Bought Garageband for iPad1 and it worked like a dream. Then I upgraded my system to 4.3 and now Garageband doesn't work. How come? When I try to start it just flickers and then goes back to show the symbol for the app.

    Bought Garageband for iPad1 and it worked like a dream. Then I upgraded my system to 4.3.5 and now Garageband doesn't work. How come? When I try to start it just flickers and then goes back to show the symbol for the app.

    I understood what you were saying. You did type 4.3.5 in your post. Several other things to try.
    Close all open apps like I described above. Just tap the home button first so that you will be able to access all of your apps. Close every single one and then restart again.
    You can also delete the app and download it again. As long as you use the same Apple ID and password there is no charge to download it again. Tap and hold down on the GarageBand app icon until it wiggles. Then tap the X to delete it. Download it again.
    Reset the iPad. Hold down on the sleep and home buttons at the same time until the Apple logo appears on the screen. It takes about 10-15 seconds. Ignore the red slider shut off bar. When the Apple logo appears you can let go of the buttons and the iPad will reboot.
    The final thing to try is to download another app - any free app. Sometimes that seems to reset something on the iPad. You can always delete the free app if you don't want it.

  • Looking for list of standard Active Directory attributes

    Hey all,
    where can I find a standard list of active dir attributes? I'm not too familiar with AD, so I'd like to know my standard options which I can query.
    I'm going to read all the adler_steven posts, so that should get me a little more aquatinted with JNDI, but I'll be back to ask some more questions!
    Thanks,
    ryan

    Thanks all.
    I got all the info I need.
    A main point to keep in mind is that connecting & searching through a OpenLDAP server is much different than connecting to an AD server.
    I couldn't find much info on the major differences, so it was tough for me to figure.
    A good adsi browser helps more than the typical LDAP browsers that are available. Also, make sure you know of the out-of-the-box settings for AD win 2003 server.
    thanks again all!
    ryan.

Maybe you are looking for

  • Error in stock updation ( T.code mb1c)

    Hi all, While i'm updating stock using mb1c transaction code the following error apearing. "Control indicators for controlling area bp01 do not exit" Please provide solution for this as early as possible. Thanks & warm regards kesav

  • Need Logic in sql

    Declare @table table (EMPIID int, NAME VARCHAR(10),Updatedate datetime) INSERT into @table values(111,'Muthu','02/13/2014') INSERT into @table values(222,'Mari','02/14/2014') INSERT into @table values(222,'Raja','02/13/2014') INSERT into @table value

  • Please help me on file upload and download

    Dear all.. i am new in this i try to apply the tutorial for file upload and download but it is old i work on net weaver 7.1 and many proery has change and i cant applyb this tutorial...

  • What does the refresh button in contacts on an iphone do

    In the top left corner of contacts opposite of the edit button there is a refresh button. Does anyone know what it does?

  • Oracle 9i and runInstaller and Slackware 8.0

    i am running Slackware 8.0, and whenever i try to run /cdrom/runInstaller, i get this error: SIGSEGV 11* segmentation violation stackbase=0xbffff2fc, stackpointer=0xbffff1c4 Full thread dump: "Finalizer thread" (TID:0x42741210, sys_thread_t:0x4d093e0