Multiple objects, multiple domains, for-loops the problem?

Hi,
I've based a small amount of Powershell code off the code I've found here: http://halfloaded.com/blog/powershell-using-posh-to-search-across-multiple-domains-in-forest/
Ideally what I'm aiming for is for it to find the current forest, enumerate the domains, and then for each domain to search for a specific user. If it finds the user it should then do something, for now just clear a value extensionAttribute8.
What I suspect is happening is it finds the users but then tries to modify them while attached to the current domain, which is child1.
Domain structure:
 - Root
   - child1
   - child2
cls
$objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$DomainList = @($objForest.Domains | Select-Object Name)
$Domains = $DomainList | foreach {$_.Name}
foreach($Domain in ($Domains))
$ADsPath = [ADSI]"LDAP://$Domain"
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher($ADsPath)
$objSearcher.Filter = "SamAccountName=testuser"
$objSearcher.SearchScope = "Subtree"
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
$userDomain = $objResult.GetDirectoryEntry()
Set-ADUser $userDomain.DistinguishedName[0] -clear extensionAttribute8
It errors with
Set-ADUser : Cannot find an object with identity: 'CN=testuser,CN=Users,DC=root,DC=company,DC=co,DC=uk' under: 'DC=child1,DC=root,DC=company,DC=co,DC=uk'.
At line:17 char:9
+ Set-ADUser $userDomain.DistinguishedName[0] -clear extensionAttribute8
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (CN=testuser,C...pny,DC=co,DC=uk:ADUser) [Set-ADUser], ADIdentityNotFoundException
+ FullyQualifiedErrorId : Cannot find an object with identity: 'CN=testuser,CN=Users,DC=root,DC=company,DC=co,DC=uk' under: 'DC=child1,DC=root,DC=company,DC=co,DC=uk'.,Microsoft.ActiveDirectory.Management.Comman
ds.SetADUser
Set-ADUser : Cannot find an object with identity: 'CN=testuser,CN=Users,DC=child2,DC=root,DC=company,DC=co,DC=uk' under: 'DC=child1,DC=root,DC=company,DC=co,DC=uk'.
At line:17 char:9
+ Set-ADUser $userDomain.DistinguishedName[0] -clear extensionAttribute8
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (CN=dttestuser,C...ita,DC=co,DC=uk:ADUser) [Set-ADUser], ADIdentityNotFoundException
+ FullyQualifiedErrorId : Cannot find an object with identity: 'CN=dttestuser,CN=Users,DC=its,DC=ad,DC=capita,DC=co,DC=uk' under: 'DC=central,DC=ad,DC=capita,DC=co,DC=uk'.,Microsoft.ActiveDirectory.Management
.Commands.SetADUser
Please help!

cls
Import-Module ActiveDirectory
Foreach ($Domain in (Get-ADForest).Domains)
#Performing Search Operation per Domain
$Objects = Get-ADObject -LDAPFilter "SamAccountName=dttestuser" -Server $Domain -Properties extensionAttribute8
Foreach ($Object in $Objects)
Set-ADUser $Object -clear extensionAttribute8
If anyone could tell me why removing the loop:
Foreach ($Object in $Objects)
And saying
Set-ADUser $Objects -clear extensionAttribute8
Errors I'd be interested. $objects only finds 1 object so having the loop makes no sense but it does seem to stop it error'ing!

Similar Messages

  • Exchange 2003 migrate to Exchange 2010 - single forest multiple domain. Active Sync problem

    Hi All, 
    I have AD single forest and multiple domain. for example, the forest domain is jakarta.co.id, and the other domain is bali.co.id.
    Exchange 2003 deployed in jakarta.co.id, User mail enabled in domain jakarta.co.id and bali.co.id.
    Then, I upgrade to Exchange 2010 (deploy in jakarta.co.id) and move mailbox from Exchange 2003 to Exchange 2010.
    All users in bali.co.id are able to access email from Owa, BlackBerry (BIS), Outlook, but cannot access from Android, Windows Phone. (Active-Sync).
    I got error information generated from https://testconnectivity.microsoft.com, as following:
    Attempting the FolderSync command on the Exchange ActiveSync session.
    The test of the FolderSync command failed.
    Tell me more about this issue and how to resolve it
    Additional Details
    Exchange ActiveSync returned an HTTP 500 response (Internal Server Error).
    Active-Sync still not work even I check option "Include inheritable permissions from this object" in security tab.
    any idea to fix this issue?
    Thanks.
    Endrik
    Endrik | blog: itendrik.wordpress.com Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
    the thread.

    Hi Sathish, 
    We are planning to migrate Exchange 2003 to Exchange 2013, all user already in Exchange 2010 and Exchange 2003 was decommissioned
    Event Viewer log as following:
    Log Name:      Application
    Source:        MSExchange ActiveSync
    Date:          1/17/2014 10:00:48 PM
    Event ID:      1008
    Task Category: Requests
    Level:         Warning
    Keywords:      Classic
    User:          N/A
    Computer:      EXC2010.jakarta.co.id
    Description:
    An exception occurred and was handled by Exchange ActiveSync. This may have been caused by an outdated or corrupted Exchange ActiveSync device partnership. This can occur if a user tries to modify the same item from multiple computers. If this is the case,
    Exchange ActiveSync will re-create the partnership with the device. Items will be updated at the next synchronization. 
    URL=/Microsoft-Server-ActiveSync/default.eas?Cmd=Sync&User=bali%5Csteveng&DeviceId=SAMSUNG123456789&DeviceType=SAMSUNGGTN7000
    --- Exception start ---
    Exception type: Microsoft.Exchange.AirSync.AirSyncPermanentException
    Exception message: A null value was received for the NTSD security descriptor of container CN=ExchangeActiveSyncDevices,CN=Steven Gerrard,OU=IT,DC=bali,DC=co,DC=id.
    Exception level: 0
    HttpStatusCode: 500
    AirSyncStatusCode: 110
    XmlResponse: 
    This request does not contain a WBXML response.
    Exception stack trace:    at Microsoft.Exchange.AirSync.ADDeviceManager.SetActiveSyncDeviceContainerPermissions(ActiveSyncDevices container)
       at Microsoft.Exchange.AirSync.ADDeviceManager.CreateActiveSyncDeviceContainer(Boolean retryIfFailed)
       at Microsoft.Exchange.AirSync.ADDeviceManager.CreateActiveSyncDevice(GlobalInfo globalInfo, ExDateTime syncStorageCreationTime, Boolean retryIfFailed)
       at Microsoft.Exchange.AirSync.ADDeviceManager.CreateActiveSyncDevice(GlobalInfo globalInfo, ExDateTime syncStorageCreationTime)
       at Microsoft.Exchange.AirSync.Command.UpdateADDevice(GlobalInfo globalInfo)
       at Microsoft.Exchange.AirSync.Command.CompleteDeviceAccessProcessing()
       at Microsoft.Exchange.AirSync.Command.WorkerThread()
    --- Exception end ---.
    I think KB817379 is not related because Exchange 2003 was decommissioned.
    Regards, 
    Endrik
    Endrik | blog: itendrik.wordpress.com Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
    the thread.

  • I recently purchased some information to be downloaded to one of my apps I never received the download and I was charged multiple times I reported the problem my  Community

    I recently purchased some information to be downloaded to one of my apps I never received the download and I was charged multiple times I reported the problem And it's been about a week my question is how long does it take  to credit my account back. It's my money and I want it now.

    It can take a while for your money to show up in your bank, but a week is a bit over the top. Try contacting iTunes Store Support to make sure the refund was issued.

  • Firefox crashing when i wanna open or close a tab or a window, also while wanna open any page, now what to do for solving the problem?

    Firefox crashing when i wanna open or close a tab or a window, also while wanna open any page, now what to do for solving the problem?

    Disable McAfee siteadvisor and check the problem still persist or not?

  • My MacBook Pro is all of sudden having issues with pop up ads.  I am running OSX 10.5.8.  Any suggestions for fixing the problem?

    All of a sudden I am getting TONS of pop up ads.  I am on a Macbook Pro running OSX 10.5.8.  Anyone have any suggestions for fixing the problem?

    Take a look at my Adware Removal Guide.
    (Fair disclosure: The Safe Mac is my site, and contains a Donate button, so I may receive compensation for providing links to The Safe Mac. Donations are not required.)

  • Code for looping the write_form

    Hi
    can anyone give me the code that  u have developed inthe past for looping the write_form F.M. please...

    Hi,
    TABLES :
      scarr,
      spfli,
      sflight.
    *PARAMETERS :
    *  p_carrid LIKE sflight-carrid,
    *  p_connid LIKE sflight-connid.
    DATA :
    BEGIN OF fs_sflight,
       carrid LIKE sflight-carrid,
       connid LIKE sflight-connid,
       fldate LIKE sflight-fldate,
       price  LIKE sflight-price,
       currency LIKE sflight-currency,
       seatsmax LIKE sflight-seatsmax,
       seatsocc LIKE sflight-seatsocc,
    END OF fs_sflight.
    DATA :
      t_scarr LIKE
    STANDARD TABLE
           OF scarr.
    DATA :
       t_spfli LIKE
      STANDARD TABLE
            OF spfli.
    DATA :
      t_sflight LIKE
       STANDARD TABLE
             OF fs_sflight.
    DATA :
      fs_options TYPE itcpo.
    START-OF-SELECTION.
      PERFORM selection.
      PERFORM open_form.
      LOOP AT t_sflight INTO fs_sflight.
        AT NEW connid.
          PERFORM start_form.
          READ TABLE t_spfli INTO spfli WITH KEY carrid = fs_sflight-carrid
                                                 connid = fs_sflight-connid.
          READ TABLE t_scarr INTO scarr WITH KEY carrid = fs_sflight-carrid.
        ENDAT.
        PERFORM write_form.
        AT END OF carrid.
          PERFORM end_form.
        ENDAT.
      ENDLOOP.
      PERFORM close_form.
    *&      Form  selection
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM selection .
      SELECT *
        FROM scarr
        INTO TABLE t_scarr.
    *          WHERE carrid = p_carrid.
      SELECT *
        FROM spfli
        INTO TABLE t_spfli.
    *          WHERE carrid = p_carrid
    *            AND connid = p_connid.
      SELECT carrid
             connid
             fldate
             price
             currency
             seatsmax
             seatsocc
        FROM sflight
        INTO TABLE t_sflight.
    *   WHERE carrid = p_carrid
    *     and connid = p_connid.
    ENDFORM.                    " selection
    *&      Form  open_form
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM open_form .
      fs_options-tdcopies = 2.
      fs_options-tddest = 'LP01'.
      fs_options-tdpreview = 'X'.
      fs_options-tdnoprint = 'X'.
      CALL FUNCTION 'OPEN_FORM'
       EXPORTING
    *   APPLICATION                       = 'TX'
    *   ARCHIVE_INDEX                     =
    *   ARCHIVE_PARAMS                    =
    *   DEVICE                            = 'PRINTER'
       dialog                            = ' '
    *     form                              = 'FORM1'
    *   LANGUAGE                          = SY-LANGU
       options                           =  fs_options
    *   MAIL_SENDER                       =
    *   MAIL_RECIPIENT                    =
    *   MAIL_APPL_OBJECT                  =
    *   RAW_DATA_INTERFACE                = '*'
    * IMPORTING
    *   LANGUAGE                          =
    *   NEW_ARCHIVE_PARAMS                =
    *   RESULT                            =
       EXCEPTIONS
         canceled                          = 1
         device                            = 2
         form                              = 3
         options                           = 4
         unclosed                          = 5
         mail_options                      = 6
         archive_error                     = 7
         invalid_fax_number                = 8
         more_params_needed_in_batch       = 9
         spool_error                       = 10
         codepage                          = 11
         OTHERS                            = 12
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " open_form
    *&      Form  write_form
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM write_form .
      CALL FUNCTION 'WRITE_FORM'
       EXPORTING
         element                        = 'FLIGHTINFO'
    *   FUNCTION                       = 'SET'
    *   TYPE                           = 'BODY'
    *   WINDOW                         = 'MAIN'
    * IMPORTING
    *   PENDING_LINES                  =
       EXCEPTIONS
         element                        = 1
         function                       = 2
         type                           = 3
         unopened                       = 4
         unstarted                      = 5
         window                         = 6
         bad_pageformat_for_print       = 7
         spool_error                    = 8
         codepage                       = 9
         OTHERS                         = 10
      IF sy-subrc <> 0.
        WRITE 'Write_Error'.
      ENDIF.
    ENDFORM.                    " write_form
    *&      Form  close_form
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM close_form .
      CALL FUNCTION 'CLOSE_FORM'
    * IMPORTING
    *   RESULT                         =
    *   RDI_RESULT                     =
    * TABLES
    *   OTFDATA                        =
    * EXCEPTIONS
    *   UNOPENED                       = 1
    *   BAD_PAGEFORMAT_FOR_PRINT       = 2
    *   SEND_ERROR                     = 3
    *   SPOOL_ERROR                    = 4
    *   CODEPAGE                       = 5
    *   OTHERS                         = 6
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " close_form
    *&      Form  start_form
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM start_form .
      CALL FUNCTION 'START_FORM'
       EXPORTING
    *   ARCHIVE_INDEX          =
         form                   = 'FORM1'
    *   LANGUAGE               = ' '
    *   STARTPAGE              = ' '
    *   PROGRAM                = ' '
    *   MAIL_APPL_OBJECT       =
    * IMPORTING
    *   LANGUAGE               =
       EXCEPTIONS
         form                   = 1
         format                 = 2
         unended                = 3
         unopened               = 4
         unused                 = 5
         spool_error            = 6
         codepage               = 7
         OTHERS                 = 8
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " start_form
    *&      Form  end_form
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM end_form .
      CALL FUNCTION 'END_FORM'
    * IMPORTING
    *   RESULT                         =
       EXCEPTIONS
         unopened                       = 1
         bad_pageformat_for_print       = 2
         spool_error                    = 3
         codepage                       = 4
         OTHERS                         = 5
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " end_form
    Regards,
    Swapna.
    Edited by: NagaSwapna Thota on Jul 4, 2008 9:14 AM

  • I wish to thank cor-el for solving the problem I expressed earlier.

    Thanks to cor-el for solving the problem I had with tiny text when I opened AOL mail. Using Ctrl-0 worked perfectly.
    Thanks very much.

    You're welcome.
    [/questions/761932]

  • Multiple domains for tracker.js

    I'm using the personalization functionality of CQ 5.4, which appears to force a request for http://localhost:4502/libs/wcm/stats/tracker.js when pages load. According to the docs at http://dev.day.com/docs/en/cq/5-4/deploying/configuring_cq.html#OSGi Configuration in the Repository , I should be able to override this URL by adding some nodes to /apps/projectName. However, my tests seem to show that doing so for one project affects all sites on the server. In production, the client has a number of domains all running on one CQ instance.
    1) Is there a way to remove this request altogether without modifying any JSPs in the /libs folder, or inheriting/overriding them?
    2) Is there a way to support multiple domains?
    The best solution I've come up with so far is creating a generic domain like cq-tracking.clientName.com, and having all sites use that.

    See the following:
    http://www.cisco.com/en/US/products/ps6120/products_configuration_example09186a00808c3c45.
    shtml
    *Perform Multi-Domain Searches (Optional) *
    *Optional.* The ASA currently does not support the LDAP referal
    mechanism for multi-domain searches (Cisco bug ID CSCsj32153).
    Multi-domain searches are supported with the AD in Global Catalog Server
    mode. In order to perform multi-domain searches, setup up the AD server
    for Global Catalog Server mode, usually with the these key parameters
    for the LDAP server entry in the ASA. The key is to use an
    ldap-name-attribute that must be unique across the directory tree.
    server-port 3268
    ldap-scope subtree
    ldap-naming-attribute userPrincipalName
    If global catalog server is not an option for you, you can always create two seperate SSL tunnel-groups and two seperate LDAP aaa-server groups and this would also allow you to do two AD domains (but the drawback is that you would have to inform the user which group they should select)
    -heather

  • Exchange 2013: how to set up multiple domain for OWA and ECP

    Exchange 2013 on Windows 2012R2
    Currently we have set this up using the guide below:
    http://mouzzamh.wordpress.com/2013/02/04/accessing-owa-from-multiple-domain-url/
    We can access OWA and ECP using the internal IP address/owa or ECP but when we use the URL it fails.
    We gave it an external IP address as well just to check if it will externally since the external DNS are pointing to the correct records: same issue it only works on IP address/owa or /ecp
    We were able to follow the guide from start to finish including the certs..
    The only difference on the guide and our exchange IIS environment for the new website is when he mentioned "Under IIS Settings / ISAPI and CGI Restrictions" we only have "ISAPI filters"...." ISAPI and CGI Restrictions" is only
    applicable to the default and backend website..
    Also, when the guide points to the path, should it be the new website path?
    Or maybe to avoid confusion, can anyone guide me on how to do it or any other guide that helped you if ever you had the same issue as mine?
    Thanks.

    Hi,
    Please run the following to check your OWA virtual directories for all web sites:
    Get-OWAVirtualDirectory | FL Identity,*URL*,path
    Personal suggestion, please consider to deploy another new CAS server. Then we can configure different OWA URLs in different servers. And pointed mail.domain.com and webmail.domain.com to two CAS servers respectively.
    Regards,
    Winnie Liang
    TechNet Community Support

  • For-Loops: The question no one asks.

    Why don't For-Loops have a premature exit capability --- i.e. why didn't
    NI include the exit capability that exists in other languages? Is it a dataflow
    thing? I don't see how. Just curious.

    Jay,
    I have to say I`m no programming Guru, but isn`t a State Maschine based on a
    case (Switch) statement? This statement does allow the user to hop to and
    fro within a certian pre-defined space, but the use of a GOTO is, as far as
    I am aware, not limited to a particular region of the code. At least with a
    switch statement (Case) the beginning point of each "choice" is well defined
    and fixed, therefore reducing the change of mistakes.
    just my 2 cents
    Shane
    Jay schrieb in Nachricht <[email protected]>...
    >
    >Hey, Tim. You say:
    >
    >>I believe that the loop exit capability wasn't included because it was
    considered
    >bad programming practice, like using goto's.
    >
    > That's funny. How can it be any worse (or different) than putt
    ing exit
    >logic into a While-Loop? As for Goto's, they're the basic logic behind the
    >much revered State Machine, and no one seems to mind that. If you're not
    >careful, State Machines can wind up producing some pretty good spaghetti
    >code, just like any text-based code can do.
    >
    >Jay
    >
    >>> Original message: Why don't For-Loops have a premature exit capability
    >--- i.e. why didn't NI include the exit capability that exists in other
    languages?
    > Is it a dataflow thing? I don't see how. Just curious.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

  • Multiple domains for vpn

    Hi,
    Is it possible to tied multiple varied AD domains ( like abc.com, ab.com) within single ssl vpn box setup.
    this is using an ASA 5540 with Version 8.0(4).
    Thanks in advance!

    See the following:
    http://www.cisco.com/en/US/products/ps6120/products_configuration_example09186a00808c3c45.
    shtml
    *Perform Multi-Domain Searches (Optional) *
    *Optional.* The ASA currently does not support the LDAP referal
    mechanism for multi-domain searches (Cisco bug ID CSCsj32153).
    Multi-domain searches are supported with the AD in Global Catalog Server
    mode. In order to perform multi-domain searches, setup up the AD server
    for Global Catalog Server mode, usually with the these key parameters
    for the LDAP server entry in the ASA. The key is to use an
    ldap-name-attribute that must be unique across the directory tree.
    server-port 3268
    ldap-scope subtree
    ldap-naming-attribute userPrincipalName
    If global catalog server is not an option for you, you can always create two seperate SSL tunnel-groups and two seperate LDAP aaa-server groups and this would also allow you to do two AD domains (but the drawback is that you would have to inform the user which group they should select)
    -heather

  • No SIM on iPad. Tried different cards, same thing. Updated and multiple reboots have solved the problem. IPad fault?

    No Sim on iPad. Tried different cards, same thing. Updated iOS and multiple reboots, no luck. iPad fault? What do I do now, ask for replacement?

    Apple has acknowledged that the "no sim card" message has been a problem for some users. iOS 5.1 is reported by MacWorld to resolve this issue. 5.1 is in development and a beta version has been seeded to developers. In the meant time I suggest contacting Apple.

  • Can I use Signal Express for multiple customers for only the one time $699?

    How do I go about distributing Signal Expresss applications to multiple customers?

    Hi Nutter,
    Unlike LabVIEW, Signal Express doesn’t have any file distribution capabilities.  If your application uses only basic features, you could install the free LE version of Signal Express on as many computers as necessary.  If you need the full capabilities of Signal Express, however, you would need to purchase a license for each customer.
    An alternative to paying for Signal Express for each customer deployment would be to generate LabVIEW code from the Signal Express project and create an executable.  This process is described in the Knowledge Base articles Generate LabVIEW VIs from Signal Express and Deploying VIs generated in Signal Express.  Note that this method requires that you have LabVIEW installed on your development computer with Application Builder capabilities.
    Regards,
    Message Edited by Luke G on 05-02-2007 12:23 PM
    Luke
    Applications Engineer
    National Instruments

  • Keeping multiple domain.sites on the same computer

    Based on reading the help info, it seemed that if I had several domain.sites in DIFFERENT folders, I could open them separately and thus keep several different sites on the same computer (which I want to do to keep my student's work). However this doesn't seem to work. Even if I rename the "main site" (in application support) something else, like domainX.site, the copy domain.site which I have on my desktop (or in another folder) remains in sync. It doesn't matter which I change, they both remain the same. So I do not see how I can do what I need to do . . . any suggetions? I am using iweb 06

    Select the domain file hit command(Apple)+d
    The two domain files (domain.sites and domain copy.sites) are completely independent from each other.
    To edit one of the two simply double click it.
    If you duplicated the domain files (command(apple+d)) changes to one will not apply to the other.
    Regards,
    Cédric

  • Objects in a FOR loop

    Can anyone see why this loop won't work?:
    for (int i = 0; i < name.length; i++)
    System.out.println(instrument[ i ].getName());
    - Where "name" is an array with 12 elements,
    - Where "instrument" is an object (there are 12 objects each named instrument1, instrument2, instrument3 etc).
    - Each instrument object has a "getName" method which returns it's name attribute.
    - And obviously there's not really any spaces in the [ i ] - i've had to do that to prevent going into italics on this board!
    I was hoping this would print out 12 lines - each line being the "name" of each instrument, but instead, on compilation i get the following error:
    error75: variable instrument not found in class
    But of course, instrument isn't a varbiable, it's an object!
    Any help would really really be appreciated :)

    thanks for replying so swiftly. Basically, i'm really really new to this so i think the best thing for me to do would be to post to whole program so far asi don't know if i've declared instrument wrongly somewhere else. In the below code i've got 2 classes within the same program:
    public class instrumentArraySearch03
         public static void main(String[] args)
        String searchCriteria;   // variables
        int searchChoice;
           String againYesNo;
        String [] name = new String[13];   // create name array
        String [] type = new String[13];   // create type array
        String [] price = new String[13];   // create price array
        name[0] = "fender";
        name[1] = "gibson";
        name[2] = "squire";
        name[3] = "casio";
        name[4] = "korg";
        name[5] = "shure";
        name[6] = "akg";
        name[7] = "mcscott";
        name[8] = "pearl";
        name[9] = "ludwig";
        name[10] = "classical co.";
        name[11] = "sax co.";
        name[12] = "violin co.";
        type[0] = "electric guitar";
        type[1] = "acoustic guitar";
        type[2] = "electric bass";
        type[3] = "acosutic bass";
        type[4] = "banjo";
        type[5] = "violin";
        type[6] = "saxophone";
        type[7] = "clarinet";
        type[8] = "flute";
        type[9] = "bagpipes";
        type[10] = "keyboard";
        type[11] = "drumkit";
        type[12] = "microphone";
        price[0] = "49";
        price[1] = "59";
        price[2] = "99";
        price[3] = "149";
        price[4] = "199";
        price[5] = "249";
        price[6] = "300";
        price[7] = "350";
        price[8] = "399";
        price[9] = "450";
        price[10] = "599";
        price[11] = "799";
        price[12] = "999";
         // testing out whether objects work  - see class at bottom of page
        instrument instrument1 = new instrument(name[0], type[2], price[3]);
        instrument instrument2 = new instrument(name[11], type[2], price[0]);
        instrument instrument3 = new instrument(name[2], type[2], price[11]);
        instrument instrument4 = new instrument(name[0], type[2], price[7]);
        instrument instrument5 = new instrument(name[4], type[2], price[8]);
        instrument instrument6 = new instrument(name[8], type[2], price[6]);
        instrument instrument7 = new instrument(name[7], type[1], price[2]);
        instrument instrument8 = new instrument(name[1], type[2], price[9]);
        instrument instrument9 = new instrument(name[5], type[2], price[10]);
        instrument instrument10 = new instrument(name[6], type[2], price[5]);
        instrument instrument11 = new instrument(name[10], type[2], price[4]);
        instrument instrument12 = new instrument(name[3], type[2], price[1]);
              for (int i = 0; i < name.length; i++)
          System.out.println("instrument name is " + instrument.getName());
    } // ends main method
    } // ends class
    class instrument
    private String name;
    private String type;
    private String price;
    public instrument(String nameIn, String typeIn, String priceIn) // constructor
    name = nameIn;
    type = typeIn;
    price = priceIn;
    public String getName()
    return name;
    public String getType()
    return type;
    public String getPrice()
    return price;

Maybe you are looking for