How to query user across multiple forest with AD powershell

Hi Guys
  Our situation like this , we have two forest ,let say forestA.com and forestB.com, and they are many subdomian in forest A.
  I'd like to write a script to the AD object information via get-adobject -identify xxxx
  My accont belongs to forestA.com , and the computer i logged on belongs to forestB.com ,A & B have forest trust.
  Now the problem is if the object i quried belngs to forestB.com ,the Get-ADObject works fine ,however if the object belongs to forestA.com ,i got the error "Get-ADObject: Cannot find a object with identify: 'xxxx' under: 'DC=forestB,DC=com'.
  So how can i have a script than can query user in both forest

Prepared this some time ago for a PowerShell Chalk & Talk. Just change the forest names and credentials. Each Active Directory cmdlet you are calling works on the current drive. So to switch between the forests you need just change the drive / location.
This is also quite nice for migration scenarios.
$forests = @{
'forest1.net' = (New-Object pscredential('forest1\Administrator', ('Password1' | ConvertTo-SecureString -AsPlainText -Force)))
'forest2.net' = (New-Object pscredential('forest2\Administrator', ('Password2' | ConvertTo-SecureString -AsPlainText -Force)))
'forest3.net' = (New-Object pscredential('forest3\Administrator', ('Password3' | ConvertTo-SecureString -AsPlainText -Force)))
'a.forest1.net' = (New-Object pscredential('a\Administrator', ('Password1' | ConvertTo-SecureString -AsPlainText -Force)))
'b.forest1.net' = (New-Object pscredential('b\Administrator', ('Password1' | ConvertTo-SecureString -AsPlainText -Force)))
Import-Module -Name ActiveDirectory
$drives = $forests.Keys | ForEach-Object {
$forestShortName = ($_ -split '\.')[0]
$forestDN = (Get-ADRootDSE -Server $forestShortName).defaultNamingContext
New-PSDrive -Name $forestShortName -Root $forestDN -PSProvider ActiveDirectory -Credential $forests.$_ -Server $forestShortName
$result = $drives | ForEach-Object {
Set-Location -Path "$($_):"
Get-ADUser -Identity administrator
$drives | Remove-PSDrive -Force
$result
-Raimund

Similar Messages

  • How to identify a user across multiple pages

    Hi,
    I'm doing a homebanking and I would like to know how to identify a user across multiple pages.
    I have already take a look at HTTPSESSION, but I didn't understand.
    Can someone help me.
    I'm send the servlet Logon.
    import java.io.*;
    import java.sql.*;
    import java.util.Date;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Cons_logon extends HttpServlet
         private Connection conexao = null;
         Login1 login1;
         public void init (ServletConfig cfg) throws ServletException
              super.init(cfg);
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   conexao = DriverManager.getConnection("jdbc:odbc:bank");
              catch (Exception e)
                   System.out.println(e.getMessage());
         public void doPost (HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
              String Suser, Spassword;
         PrintWriter out;
              res.setContentType("text/html");
    out = res.getWriter();
    String opcao = req.getParameter("log");
    Thanks

    I would recommend using the authentication mechanism that's guaranteed by the servlet spec. If you do that, you can just call
    request.getRemoteUser()
    to get the user name across multiple pages.
    If you want to use your own login scheme, you can create a new session object and map it to a user name somewhere in your app. Or you can just put the name of the user on the session. But the preferred way is to use the default authentication scheme defined by the spec.

  • How to send notifications to multiple person with same role and with result

    How to send notifications to multiple people with resultout as approve/reject?
    We are looping the notification by attaching a cursor query to find the different emp nos to send for approval.
    I cannot associate a role because these emp nos are sub-set of a role which I have created and i am getting thru the cursor query.
    For FYI notification there is no problem, but for approval notification, I am not unable to send approval notifications to all the people.It stops at the first person in the loop.Pls suggest alternate way. Thanks in advance.

    Manju,
    I would use the cursor to populate the API for creating an ad-hoc role within the workflow process as a function. Then set your notification performer as the ad-hoc role.
    Here is an example function:
    create or replace procedure sample_emp_fill(itemtype in varchar2,
    itemkey in varchar2,
    actid in number,
    funcmode in varchar2,
    resultout in out varchar2) as
    cursor get_name is
    select ename from scott.emp where mgr = 7839 and empno != 7566;
    role_name varchar2(50);
    names varchar2(500);
    begin
    if (funcmode = 'RUN') then
    role_name := 'ad_hoc_role_'|| itemkey;
    for row in get_name loop
    names := names || row.ename || ' ';
    end loop;
    WF_DIRECTORY.CreateAdHocRole( role_name=>role_name,
    role_display_name=>role_name,
    language=>'AMERICAN',
    territory=>'AMERICA',
    role_description=>role_name,
    notification_preference=>'QUERY',
    role_users=>names,
    email_address=>' ',
    fax=>'',
    status=>'ACTIVE',
    expiration_date=>'');
    resultout := wf_engine.eng_completed||':'||wf_engine.eng_null;
    return;
    end if;
    end;

  • HOW TO cache user clicks on links with attributes such as "_blank" ?

    HOW TO cache user clicks on links with attributes such as "_blank" in Adobe AIR with JS or MXML or AS3 for creating new costume browser window (AIR) ?

    >This feature is indeed new to 8.5.
    Can you explain a bit more on what is possible in version 8.5? How easy it is to attach events to different sections of the 3D model? How easy it is to handle such events? I assume the events will fire even if the user rotates the 3D model via the camera control, right? Any limitations on the 3D model or what types of events are supported? If you have LV documentation describing this feature then that would be *very* helpful!
    Thanks for your reply
    MZ2

  • How to create user editable Crystal Report with dynamic dataset

    What I would like to achieve:
    A program loads a report in runtime updates list of database fields (possibly includes sample data), open report in "Crystal Reports 2011" (or 2008) where user customizes report and saves it. Later on the program loads the report, fills actualized data and displays it in .net report viewer.
    What I do:
    CrReport = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    CrReport.Load(TemplateFilename)
    Dim Results As DataTable
    DataTable is filled from a database
    CrReport.SetDataSource(mResults)
    CrReport.SaveAs(NewReportPath, True)
    The NewReportPath is opened in the default program.
    What are the problems
    The report is open in preview mode (not in design).
    When the field is added to the report the designer asks for XML datasource on preview.

    The short answer is that it is not possible. I broke the question to other two: How to save a report that it opens without preview? and How to create user editable Crystal Report with dynamic dataset, where it is possible to find details. Key answer is Re: How to create an editable previewable report?

  • How do I total across multiple Tables? Help!

    how do I total across multiple Tables? Help!
    I feel like a complete noob.

    Hi Marc,
    There is no function explicitly for that sort of array calculation in Numbers.
    My favorite way is to use a list of Table Names and the INDIRECT(ADDRESS) function combination to produce a SUM across tables. I'm making the assumption that you want to do something like adding up all the values in a particular cell of multiple tables.  For example "give me the total of all the A1 cells in tables T1, T2, T3 and T4".  For this I would use the formula:
    =INDIRECT(ADDRESS(1,1,1,,A))
    to grab the cell contents of the table names mentioned in column A of a summary table.  Once you have them collected in your summary table, add them up.
    Here's a screen shot...
    Hope that gives you an idea for approaching this problem.
    Jerry

  • User selecting multiple UIButtons with touch and drag

    I am wondering if it's possible to have a user touch and drag across multiple buttons so that I can tell which buttons have been selected.
    This is similar to to a matrix of buttons in OS X. If a user clicks and drags over a number of buttons, there is an array that can be read to see which were 'selected'. I don't see a UIMatrix and Embed Objects In menu in Interface Builder while in iPhone development only gives a View selection.
    Thanks!

    It seems this is being done by others. However, right now, I'm tracking the touch location and manually figuring out which button is under the drag. I let the underlying view be the user interaction and turn off the interaction on the UIButtons themselves. Yet, this seems to task the processor quite a bit and it takes too long to highlight the UIButtons.
    It's such a simple thing for OS X, I can' believe they dropped this functionality on the iPhone. Can anyone please give some hints as to something to try here.
    Thanks.

  • WDS Across Multiple Offices with Multiple Computers

    Im trying to set up WDS to deploy windows 7 pro across multiple computers. I work in a company that installs computers for dental offices. We have a master image and at the time to prep all computers we clone that image using Acronis. Is there a better
    way to do this? Also will WDS allow me to deploy images to different types of PCs. Right now our image only works on newer computer but we constantly rebuild older PC's that get infected. Can I make a master Image that allows me to deploy it to any computer?
    Lastly, could I do something to be able to deploy this into our offices, if so how? Would I need to set up all those servers?

    Hi JDAM-00,
    Are you trying to
     create the universal image, which means .create a single image and deploy to multiple hardware. You were unable to create the universal image by sysprep tool it is not supported, but you can use MDT or WDS and inject drivers in the driver
    store then it's possible to deploy the image.
    The related information:
    Microsoft Deployment Toolkit
    http://technet.microsoft.com/en-us/solutionaccelerators/dd407791.aspx
    Microsoft Deployment Toolkit (MDT) Demo: Using MDT to quickly and efficiently deploy Windows 7 across your organization
    http://technet.microsoft.com/en-us/edge/gg552673
    MDT 2010 New Feature #19: Improved Driver Management
    http://blogs.technet.com/b/mniehaus/archive/2009/09/09/mdt-2010-new-feature-19-improved-driver-management.aspx
    More detail about the MDT question you can ask in the specific MDT support forum.
    MDT support 
    forum:
    https://social.technet.microsoft.com/Forums/en-US/home?forum=mdt
    I’m glad to be of help to you!
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to simulate users workload in CIC0 with CATT

    Hello,
    I would like to generate workload of CRM users with CATT. Users will work only with transaction CIC0. A typical session contain:
    - search Businness Partner according partner id,
    - double click on Operation
    - click on tab "Fact Sheet"
    I detect, that CATT unable to double click on "Operation" sub-window. The same problem is in tab "Fact Sheet" overview. I think, that CATT is not possible to do this!
       Please, could you tell me ... is CIC0 and CATT good idea how to generate user workload?
       Best regards ...
       Martin Hucl, Logica.

    I don't use the Quest tools, so this is a guess based on the less-than-helpful documentation:
    Get-Content .\userList.txt | ForEach {
    Get-QADUser -ObjectAttributes @{EmployeeID=$_} -IncludedProperties EmployeeID
    } | Select EmployeeID,DisplayName,SamAccountName
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)

  • How to sync contacts across multiple devices

    I have a iPhone, iMac and iPad that I am having trouble keeping my contacts in sync!
    Some contacts do not appear across all devices and others appear duplicated on one or more device.
    After much checking of the settings and trying to merge contacts, I have still not managed to sort the problem.
    David

    First check that all your settings are correct, that contact syncing is checked on all devices (system preferences > iCloud on a mac and settings > iCloud on a iPhone, iPad or iPod).
    Make sure the contacts you are adding are added to your 'iCloud' group and not an 'On My Mac', 'On My Phone' or other non iCloud group (you can do this by checking in groups), non iCloud contacts will not sync.
    If you are sure that everything is set up correctly and your contacts are in the iCloud group, you might try unchecking contact syncing in the iCloud settings, restarting your device and then re-enabling contact syncing.
    This user tip might help you understand how accounts work with Address Book.

  • Splitting up a job for 140k+ users across multiple servers

    Hello, 
    I am pretty new to Powershell and want to learn more about scaling stuff and just started working with jobs.
    In this particular case I am just doing mass enable or disable at a per user level.  The other script I need to do this with grabs and checks values on around 6000 distribution groups and using the current values and type it creates new commands
    to add/remove certain users or permissions in bulk with Invoke-Expression.  I *think* it would probably be best in my case to run these across servers as well.
    Basically what I am looking at is:
    Using one large list/array, counting it, splitting it, using the resources it has available with jobs.
    One of the problems I have had with this but seems I have mostly figured out is how I combine or 'foreach' several different values that may need to be applied to separate objects on certain servers with certain users and certain attributes. 
    Last night I ran the first script that could do that but it took me awhile and looks like a wreck I am sure - but it worked!
    Now to tackle size.
    Thank You

    Hi Paul,
    looking good so far. Did a little rewrite of what you posted:
    Function Disable-Stuff
    Param (
    [Parameter(Position = 0, Mandatory = $true)]
    [string]
    $file,
    [Parameter(Position = 1)]
    [ValidateSet('CAS', 'MBX', 'ALL')]
    [string]
    $servertype = "CAS"
    # Collect server lists
    $servers = @()
    switch ($servertype)
    "CAS" { $servers += Get-ClientAccessServer | Select -ExpandProperty name }
    "MBX" { $servers += Get-MailboxServer | select -ExpandProperty name }
    "ALL"
    $servers += Get-ClientAccessServer | Select -ExpandProperty name
    $servers += Get-MailboxServer | select -ExpandProperty name
    # Remove duplicate names (just in case)
    $servers = $servers | Select -Unique
    default { }
    # Calculate set of operations per server
    $boxes = ($servers).count
    $content = Get-Content $file
    $split = [Math]::Round(($content.count / $boxes)) + 1
    # Create index counter
    $int = 0
    # Split up task
    Get-Content $filepath -ReadCount $split | ForEach {
    # Store file content in variable
    $List = $_
    # Select Server who does the doing
    $Server = $servers[$int]
    # Increment Index so the next set of objects uses the next Server
    $int++
    # Do something amazing
    # ... <-- Content goes here
    Disable-Stuff "c:\job\disable.txt" "CAS"
    Notable changes:
    Removed the test variables out of the function and added them as parameters
    Modified the Parameters a bit:
    - $file now is mandatory (the function simply will not run without it)
    - The first parameter will be interpreted as the file path
    - The second parameter will be interpreted as Servertype
    - $Servertype can only be CAS, MBX or ALL. No other values accepted
    - $Servertype will be set to CAS unless another servertype is specified
    you if/ifelse/else construct has been replaced with a switch (I vastly prefer them but they do the same functionally
    I removed the unnecessary temporary storage variables.
    Appended a placeholder scriptblock at the end that shows you how to iterate over each set of items and select a new server each time.
    I hope this helps you in your quest to conquer Powershell :)
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • Best way to have multiple emails across multiple Macs with Mail?

    So I have 2 Macs, and 3 email accounts (GMail, GoDaddy, and my university)...and I have all accounts set up on both machines, but I only receive email on one of them...if both are open, they randomly go to one, and if only one is open, it goes to the open one. How can I set it up so that all emails go to BOTH computers?
    Thanks!

    Scott,
    Looking for some support/advice on a multiple-computers/same account issue.
    One group that I do some IT for have about 12 staff members, each armed with a laptop (Mac of course). Their mail accounts are set up as POP (as recommended by our hosting company ((paetec)) due to the volume of messages). Everyone likes POP.
    There are three administrative assistants at the main office who monitor/check the POP accounts for the staff who are off-site with laptops. So "joe" is checking/sending e-mail on the road from his MacBook, and his assistant is also checking/saving "Joe's" mail back at the office. The staff want it set up this way and depend on this double checking system (no sales/customer inquiry is ever missed)
    Is this a recommended use of Mail.app? Anyone else use a similar set up?
    So, let's say the admin staff have about 10 to 12 accounts on their iMacs, constantly fetching the same mail the POP users may or may not have read yet.
    A big problem I have is a bulk of junk/spam/old messages that are piling up on the server. I don't know why their are so many (in the GBs), because I try to keep everyone's Mailbox Advanced settings the same (download to the local machine, remove from server, after so long). But it is not working.
    The messages on the server pile up and I don't know why. Without having everyone's laptops in front of me, or checking all their settings through Remote Desktop, I'm not sure where the problem is?
    Another problem is the occasional re-download of duplicate messages from the server to a specific POP account. What triggers Mail.app to do that? A date, a file size, a bug? That is when the tons of un-removed mail from the server really ties up/slows down the admin assistant's mail.app.
    (which I thought was removed!)
    Any advice/thoughts welcome.
    Thanks
    bc

  • Spreading users across multiple AP's

    Hi
    I have a requirement to provide Wireless to over 250 people in one big arena. I am thinking of using an Lwapp install but was wondering how will I force users to associate evenly across all access points. I want to avoid the situation whereby 30 associate with AP1 and 5 associate with AP2
    Any help would be appreciated

    Hi Martin,
    Hope so everything's fine at your end.
    Typically Ap1200's or LWAPP AP's manage load balancing internally on their own using the Auto-RF features if you are using some 4000 series controllers dunno about others. So this auto-rf features should equally load balance the client across all Ap's, well if that doesn't happen for som e reason then, you may change the configuration to do that.
    You may create seperate wlans to be broadcasted through different lwapps with seperate ssid's.
    For example,
    AP1200-1 broadcasts wlan 1 connecting around 35 clients
    AP1200-2 broadcasts wlan 2 connecting another set of 35 or more.. and so on.
    AP1200-3 broadcasts wlan 1 again but is at a distance of say more than 100 feet or so connecting another set of 35 or more.. and so on.
    Please feel free to contact me if you need any more assistance.
    Thanks & Regards,
    Karthik Narasimhan

  • How to query over a child field with WebServices (QueyPage)?

    Hi,
    I am using Account WS 1.0, and I would like to do a query to retrieve all assets in a specif account with one filter in the Account element and other filter in the Asset element. For the first one, I haven't problems, but with the second I can't do the query with a filter (it has the particularity to be a numeric field).
    This is my source code:
    listAssetAccountQuery[0] = new Account();
    listAssetAccountQuery[0].setAccountId("");
    listAssetAccountQuery[0].setId_Client("='"+idAccount+"'");
    assetAccount[0] = new Asset();
    assetAccount[0].setAssetId("");
    assetAccount[0].setProduct("");
    assetAccount[0].setNCodeProd("= "+idProd); <---- Here it is the problem. If I try with assetAccount[0].setNCodeProd(""); I have results.
    // The error is: javax.xml.rpc.soap.SOAPFaultException: Text unexpected: ='200200'(SBL-EAI-13010)
    listAssetAccountQuery[0].setListOfAsset(assetAccount);
    AccountWS_AccountQueryPage_Output resultQuery = myPort.accountQueryPage(null, "true", null, "100", listAssetAccountQuery, "false", "0");
    How can I do the filter for NCodeProd¿? I have tested too with:
    assetAccount[0].setNCodeProd("='"+idProd"'");
    But the issue is the same.
    I am not sure if it is correct this association to do a query between a parent and child object. Is this correct?
    Thank you in advance and regards.

    Hi,
    By default the criteria between the parent and child is "or" ed. The query you have specified is
    account.Id_Client='idAccount' or account.asset.NCodeProd='idProd'
    if you are looking for an "AND" operation then set the "UseChildAnd" parameter to true. This API should be avialable in your XXXWS_XXXQueryPage_Input object.
    Also, only a subset of child fields are filterable. Look at the web Services user guide to make sure the NCodeProd field of Asset is filterable.
    hope this helps.
    Cheers,
    Edited by: 789631 on Oct 28, 2010 10:38 AM

  • How to I set up multiple devices with iMessage so I don't have multiple conversations?

    My family has two iTouchs and 2 iPhones. I have all 4 set up on the same apple ID so when purchases are made from the app store or iTunes then is comes from one account.  The problem I am having is texting. When the iPhones text either of the iPods it comes from the email address linked to the apple ID.  Therefore the iTouch users can't tell which phone it came from (ie mom or dad).  Sometimes however it will show up on the iTouchs from the iPhone phone numbers. Sometimes when sending a message from iPhone to iPhone it will show up as sent from the email address associated with the apple ID.  My questions is is there a way around this or do I need to set up a different apple ID for each unit? 

    Not in one boot system. The only way I can think of doing what you want is to dual-boot - ie, either partition a single drive with two volumes, one for each configuration, or, if you can, use separate physical drives. The Matrox drivers are loaded at the system level, not the user level.
    If you have a spare drive, you would just clone your system across using Carbon Copy Cloner / SuperDuper, then boot to the second system and adjust the drivers as necessary.
    Matt

Maybe you are looking for

  • I want a dropdown where the parent item is not a link

    I have a dropdown menu  that is filled with links to the pages that are attached to a parent page. But I don't want the parent to be a link.  People are confused (they tell me) if the hover over the title of the dropdown that the parent is a link to

  • My iMac OSX keep shutting down

    My iMac OSX keep shutting down randomly. It goes to a black screen to a blue screen and then shuts off. I have to unplug and replug it in to get it going again. It's happening everyday... has anyone had this problem and if so what did you do to fix i

  • Pagemaker 7 - XP - Screen problems

    I am running PageMaker 7.0 English version on a PC (XP SP 3) English version. My monitor is a Mirai 22" with 1680x1050 resolution, 32 bit color. A few months ago I produced a small book without problems, but today I am getting problems with my monito

  • Showing Visual composer iviews within Web Page Composer (wpc)?

    I am able to integrate KM iviews from the PCD into my web page composer pages, but when I try showing Flex 2 iviews generated by Visual Composer the flash runs on top of everything else on the page. The flash is simply put at page coordinates 0 x 0 w

  • Brand new iPod won't turn on.

    I've recently purchased a 30GB iPod video, but it does not seem to work. I've studied the help documents to the best of my abilities and consulted friends who also own iPods, but have yet to find out how to solve my problem. As the subject line says,