Mounting and Unmounting NTDS.dit file

Hi,
I am creating a PowerShell script that will give a possibility to mount the NTDS.dit file from the backup and compare the Backup AD with the current AD. If you are interested I can share the unfinished script. The problem is that I want to moun the NTDS.dit
file in a scripted maner. When you mount the file manualy using:
dsamain -dbpath "<path_to_the_NTDS.dit_file>" -ldapPort 10389
the process starts normaly but to end it the user needs to press "Ctrl+C" and once the process is running the script will not conitnue. I want to stop ager certain amount of time. I tried different ways starting the command as different process
(e.g.
cls
$w1 = ""
$w2 = ""
get-process -name powershell -ErrorAction SilentlyContinue | Foreach-object {$w1 = @();$w1 += $_.ID}
start-process powershell.exe -argument '-nologo -noprofile -executionpolicy bypass -command "dsamain -dbpath "<path_to_the_NTDS.dit_file> -ldapport 33389"'
Start-Sleep -Seconds 10
get-process -name powershell | Foreach-object {$w2 = @();$w2 += $_.ID}
$e = Compare-Object -ReferenceObject $w1 -DifferenceObject $w2
$e1 = foreach ($r in $e) {if($r -like "*=>*"){ $r }}
$e1 | Foreach-object {$y = @();$y += $_.InputObject}
Start-Sleep -Seconds 600
stop-process -id $y
and
Start-Process "Powershell.exe" -WindowStyle Hidden -ArgumentList "
  Start-Job -Name 'Mounting the NTDS.dit' -ScriptBlock {
    Do
        # --- This will mount the ntds.dit file from the backup ---
        dsamain -dbpath $NTDS_File -ldapPort $LDAP_PortNumber
    Until ($False)
    }; Start-Sleep -s $time_ntds
But both commands don't allways work. I was browsing other solutions and came accross the main article of
dsamain:
Active Directory Domain Services Database Mounting Tool (Snapshot Viewer or Snapshot Browser) Step-by-Step Guide
and little bit from top of the "Steps for using the Active Directory databse mounting tool" there is a line that says:
"..You can stop Dsamain by pressing CTRL+C in the Command Prompt window or, if you are running the command remotely, by setting the
stopservice attribute on the rootDSE object. "
Can anyone tell me how to use stopservice, e.g. give example scripts or equivelent.
Or if anyone has any other ideas how to acomplish the task I would be more than happy to hear them out and try.

Solved it by using this command:
                      $time_ntds = 10
                      $time_ntds = $time_ntds*60                  
                      Start-Process "Powershell.exe" -WindowStyle Hidden -ArgumentList "
                        Start-Job -Name 'Mounting the NTDS.dit' -ScriptBlock {
                          Do
                                # --- This will mount the ntds.dit file from the backup ---
                                dsamain -dbpath $NTDS_File -ldapPort $LDAP_PortNumber
                          Until ($False)
                        }; Start-Sleep -s $time_ntds
                    start-sleep -Seconds 35
Atis Smits

Similar Messages

  • List DNS zones on a NTDS.DIT file is it possible?

    Hi guys,
    is it possible that after mounting an active directory database NTDS.DIT file to list the DNS zones that existed in that domain controller active directory integrated zones?
    I have mounted successfully the AD database using
    dsamain.exe -dbpath “C:\path\to\ntds.dit” -ldapport 5532 -allownonadminaccess -allowupgrade
    and now i can see it on dsa.msc console. But since the DNS folder on that drive didn't had the DNS zone files i assume this are embedded on the database as they were AD integrated.
    Thanks in advance for any information.

    Simply use ldp.exe and you then you can go under:
    CN=MicrosoftDNS,DC=DomainDnsZones,DC=Domain,DC=COM
    CN=MicrosoftDNS,DC=ForestDnsZones,DC=Domain,DC=COM
    This is an example of article about how you can use ldp.exe: https://ramazancan.wordpress.com/2009/12/11/dsamain-%E2%80%93-active-directory-database-mounting-tool/
    This posting is provided AS IS with no warranties or guarantees , and confers no rights.
    Ahmed MALEK
    My Website Link
    My Linkedin Profile
    My MVP Profile

  • Restore Active Directory on Server 2008 using NTDS.DIT file

    hello
    I have NTDS.DIT file with me and want to restore it on same hardware with same host name and IP
    Please help

    Hi Rochak,
    You have only the NTDS.DIT file? 
    No its not possible to restore the AD only using NTDS.DIT. You need to have the System state backup.  
    System state backup and restore operations include all system state data: you cannot choose to backup or restore individual components
    due to dependencies among the system state components. However, you can restore system state data to an alternate location in which only the registry files, Sysvol directory files, and system boot files are restored. The Active Directory database, Certificate
    Services database, and Component Services Class Registration database are not restored to the alternate location.
    http://technet.microsoft.com/en-us/library/cc938537.aspx
    Regards,
    Rafic
    If you found this post helpful, please give it a "Helpful" vote.
    If it answered your question, remember to mark it as an "Answer".
    This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

  • Mount and Unmount

    i creating a database just to practice and sharpen my skills since i've been out of school for a while. someone suggested i do some of the following transactions like creating clusters and mounting and unmounting the database. I've found info on creating clusters, but haven't found anything on mounting and unmounting an oracle database. can someone please assist me with this?
    thanks,
    YR

    Hi..
    Have you created a database.You can create the database using DBCA utility and also maually.
    for manually creating the database [http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5004.htm#SQLRF01204]
    In Mount stage :- To mount the database, the instance finds the database control files and opens them. Control files are specified in the CONTROL_FILES initialization parameter in the parameter file used to start the instance. Oracle then reads the control files to get the names of the database's datafiles and redo log files.
    Go through [http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/start.htm#sthref569]
    [http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/startup.htm#sthref1915]
    HTH
    Anand

  • Mounting and Unmounting USB drives [Solved]

    HI there:
    I want a program like in KDE that will automaticly mount and allow me to click to unmount my usb drives. I am building machines and I need them to be user friendly and fast. I am running openbox 3.5 with a lxpanel right now. Also how do you allow users to access the usb drives. Here is an example of an error. I am logged in as usera. I fire up shotwell plug in my camera. It detects it I click on the camera and it says
    "Shotwell
    Unable to fetch previews from the camera:
    I/O problem (-7)"
    I log in as root it works perfectly. I hope this all makes sense.
    Last edited by mich04 (2011-10-27 23:36:30)

    AliWam wrote:
    How do you start openbox?
    I am using startx with this ~/.xinitrc
    exec ck-launch-session dbus-launch openbox-session
    and it works well.
    Have a look here.
    Nice!  I just installed Xfce on my new netbook (I use awesome WM and a different automounting solution for my other Arch box) and adding "dbus-launch" right before "startxfce4" on the line that reads:
    "exec ck-launch-session dbus-launch startxfce4"
    fixed my problem.
    I'm a little confused though, in the wiki it says that, "In case you are wondering, dbus-launch will be launched by the xinitrc.d code at the beginning of the file...."  https://wiki.archlinux.org/index.php/Xfce
    My .xinitrc is functionally the same as the example in the wiki, so I had thought that somehow dbus-launch wouldn't be necessary.  Oh well, it's working now and that's all that matters, thanks for your suggestion AliWam!

  • What is the volume 'ldap_bk' that Mounted and Unmounted every hour or two?

    What is the volume 'ldap_bk' that do Mounted and after 5 to 10 secs Unmounted ? This happen every hour or two.

    I am getting similar kernel panics, usually once a day, on my 2006 Xserve running 10.6.8 server. I have 6 ECC enabled 2GB sticks installed, with DIMM slots 7 & 8 empty. All DIMMS show no ECC errors. The first for slots are filled with RAM from vendor A, with slots 5 & 6 filled with RAM from vendor B.
    panic(cpu 3 caller 0x28fc2e): "TLB invalidation IPI timeout: " "CPU(s) failed to respond to interrupts, unresponsive CPU bitmap: 0x10, NMIPI acks: orig: 0x0, now: 0x0"@/SourceCache/xnu/xnu-1504.15.3/osfmk/i386/pmap.c:3572

  • Why is my refurbished Ipod shuffle 2nd generation mounting and unmounting?

    I got a 2nd generation Ipod shuffle for christmas and I plugged it into my computer and it wont stay mounted.
    It will mount and then a few seconds later it will unmount, then a few seconds later it will mount again, and then unmount and so on and so fourth. What can I do to successfully mount my ipod so i can put music on my christmas gift?

    Do you have the latest version of iTunes installed?
    Are you using the cable that originally came with the shuffle?  It has a mini-dock on shuffle end of the cable.
    As a test, you should try shutting down your computer and disconnecting all USB devices, including hub.  You can keep standard keyboard and mouse connected, if normally used.  If your computer is a laptop, connect its power adapter, so that it is not running on battery power.  Do this to reset the shuffle
    http://support.apple.com/kb/ht1655
    Start up the computer, run iTunes, and connect shuffle to a direct USB port on the computer.

  • [SOLVED] advanced shell script for mount and unmount samba share

    Good morning guys,
    Today I've a very long question....
    Hope in your help....:
    I usually move from different network.
    For one of those I need to mount some share that are under an ActiveDirectory server.
    To do that I use samba.
    Especially I've made and use the below  shell script.
    I know that it's so stupid but I'm a very newbie:
    #!/bin/sh
    echo "This is a custom script for mount my citrix share"
    echo "Please insert user password (must a sudoer user)"
    echo " "
    sudo mount -t cifs -o username='myusername',password='mypassword' //host_ip/TsHome$/myusername /home/myuser/samba_share/TsHOME
    sudo mount -t cifs -o username='myusername',password='mypassword' "//host_ip/direction" /home/myuser/samba_share/direction
    echo " "
    read -p "Press ENTER key to close this terminal"
    exit
    As I say the script work but it's so crude...!
    I want/need to implement it whit the follow addictions:
    1. print a feedback on mount: somenthing like "TsHOME is now mounted" or "unable to mount TsHOME"
    2. check if the share are already mounted: to prevent accidentally multiple mount. If a share is already mounted I want to print something like "TsHOME is already mounted on /home/myuser/samba_share/TsHOME"
    3. ask for share password  (now it's in clear on script) - This is optinal
    4. un-mount the share before reboot or shutdown command. That because I've notice that If i reboot or shutdown without manually un-mount the share the step of unmounting network file system became very slow
    If it's no extremely difficult, can someone help me to write this script?
    I know that man exist but I'm not a programmer and it's so difficult for me approch it.
    Thank you in advance.
    Ale
    Last edited by Alexbit (2010-09-23 21:29:13)

    Thank you very (VERY) much!
    I've follow your information and.. it work!
    If can be usefull to other this is the complete script:
    #!/bin/sh
    echo "This is a custom script for mount citrix share"
    echo "****************************************"
    echo " "
    echo "Please insert domain password:"
    read -s mypassword
    echo " "
    echo "|checking mount state...in share are not mounted mount it!|"
    echo "+-------------------------------------------------------------------------+"
    if grep "TsHome" /etc/mtab &>/dev/null; then
    grep "TsHome" /etc/mtab | awk '{print "TsHome is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" //ipaddress/TsHome$ /home/Samba_share/TsHOME && echo "TsHOME is now mounted" || echo "unable to mount TsHOME"
    fi
    echo " "
    if grep "direction" /etc/mtab &>/dev/null; then
    grep "direction" /etc/mtab | awk '{print "direction is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/direction' /home/Samba_share/direction' && echo "direction pat is now mounted" || echo "unable to mount direction"
    fi
    echo " "
    if grep "Area" /etc/mtab &>/dev/null; then
    grep "Area" /etc/mtab | awk '{print "Area is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/Area' /home/Samba_share/Area && echo "Area is now mounted" || echo "unable to mount Area"
    fi
    echo " "
    echo "All DONE!"
    echo " "
    read -p "Press ENTER key to close this terminal"
    exit
    I don't really well understand what I've to put in rc.local.shutdown....
    I think somethings like:
    #!/bin/bash
    # /etc/rc.local.shutdown: Local shutdown script.
    echo "This is a custom script for UN-mount citrix share"
    echo "********************************************"
    echo " "
    echo "|check mount state: if mount then un-mount!|"
    echo "+-------------------------------------------------------+"
    echo " "
    if grep "TsHome" /etc/mtab &>/dev/null; then
    grep "TsHome" /etc/mtab | awk '{print "TsHome is NOT mounted -> going on..." $2}'
    else
    sudo umount /home/Samba_share/TsHOME && echo "TsHOME is now UN mounted" || echo "unable to UN-mount TsHOME"
    fi
    echo " "
    if grep "direction" /etc/mtab &>/dev/null; then
    grep "direction" /etc/mtab | awk '{print "direction is NOT mounted -> going on.." $2}'
    else
    sudo umount /home/Samba_share/direction && echo "direction is now UN mounted" || echo "unable to UN-mount direction pat"
    fi
    echo " "
    if grep "Area" /etc/mtab &>/dev/null; then
    grep "Area" /etc/mtab | awk '{print "Area is NOT mounted - Finished" $2}'
    else
    sudo umount /home/Samba_share/Area && echo "Area is now UN mounted" || echo "unable to UN-mount Area"
    fi
    echo " "
    echo "going shutdown"
    echo " "
    sleep 5
    I've try but it seems to ignore the IF statement... this is the output when ALL share are UNmounted:
    $ sh /etc/rc.local.shutdown
    This is a custom script for UN-mount citrix share
    |check mount state: if mount then un-mount!|
    +-------------------------------------------------------+
    umount: /home/Samba_share/TsHOME: not mounted
    unable to UN-mount TsHOME
    umount: /home/Samba_share/direction: not mounted
    unable to UN-mount direction
    umount: /home/Samba_share/Area: not mounted
    unable to UN-mount Area
    going shutdown
    Tomorrow I will test again when I'm at office.
    Meanwhile can you check if I made a macroscopic mistakes?
    Thank you again!
    Last edited by Alexbit (2010-09-23 17:34:49)

  • Mounting and unmounting drives

    Do you have to un-mount an external firewire drive in OS 9 like you do with OS X? Normally in OSX you unmount the drive before powering it down. Does the firewire drive auto mount when you connect it in OS 9? I run OSX but my Dad still uses OS9.2 and I'm planning to get him a firewire drive.
    Also, what format do you use when you first set it up? I think the drive comes setup or XP (I'm looking at a Lacie 80G external drive).
    Thanks,
    Alfredo

    Hi, Alfredo -
    If the computer is powered off, the drive will unmount and you can turn off the drive after the computer powers down.
    Yes.
    When the computer is powered up, is it better to first power up the firewire, or can you wait until the computer is up and running to turn on the firewire drive?
    Either - but, if you intend to have the drive available during that session, it's better to have the drive powered up before booting the Mac. There have been a few reports of a firewire device in 'off' status but still connected being the cause of an OS upset.
    Is there an un-mount command in OS 9, incase you want to disconnect it and not power down the computer.
    Yes.
    You can drag the icon of the firewire drive to the Trash (same method as ejecting a floppy or zip disk).
    Or, select the icon of the drive (click on it once) and use the Put Away instruction (Command-Y) in the File menu.
    It is not a good idea to use the Eject instruction (Command-E) in the Special menu - too often that instruction will not work completely.

  • Unix drive mounting and accessing with Receiver File(NFS) Adapter

    Hi gurus,
    Is it possible to access a mounted directory between a storage(unix) server and PI server, by using the File Adapter in NFS mode to write files to it?
    Regards,
    Gökhan

    Hi,
    >>Is it possible to access a mounted directory between a storage(unix) server and PI
    why not?
    in case your PI is on windows and storage on unix you just need
    to have samba installed on your unix machine and you can access
    unix with //server/folder/ from PI
    Regards,
    Michal Krawczyk

  • Problems with mount and unmount of network shares

    Hi,
    I use an Apple script to mount four network shares during startup of an OS 10.4.4 Powerbook. Unfortunately it seems that Tiger can't always mount them all. Sometimes it only mounts three of them, but pressing Command + K indicates that the fourth is already mounted because it's grayed out. How come I can't see it on neither the desktop nor the favorites list in a Finder window then?
    I have a Tiger installation at home with Ciscos VPN Client 4.8 installed. I use that VPN client to gain access to the company's network. When the connection is established, I mount a share (with AFP over TCP/IP) on the company's server running Win2003 and ExtremeZ-IP.
    When I close down Ciscos VPN Client, the mounted network share doesn't unmount automatically, and if I forget to toss that network drive in the trash before closing down or restarting my Mac, it hangs. Why can't it just unmount that drive automatically when the VPN connection is gone?
    Regards
    Thomas G. Madsen
    Powermac G5 (2 x 1.8 Ghz)   Mac OS X (10.4.4)  

    This may happens because broadcasts do not go through an IPSec tunnel.
    Browsing Network Neighborhood is a function of the Microsoft browsing service. Any problems are usually because the PC or master browsers do not function properly. Network Neighborhood is officially not supported. However, it works if configured correctly. Browsing Network Neighborhood works by obtaining the browse list from either a master or backup browser. This list is obtained locally on your LAN by using NetBIOS Broadcasts to locate domain browsers.
    Inorder to resove this :
    Make sure you have NetBIOS over TCP enabled on the adapter that you use to connect to the domain.
    Refer this related links:
    http://www.cisco.com/en/US/products/sw/secursw/ps2308/products_tech_note09186a0080194b4a.shtml

  • Mounting and unmounting digital camera

    When I connect my SONY HX9V via USB to my iMac, normally 3 devices get mounted:
    'PMBPORTABLE', 'NO NAME' and another 'NO NAME'.
    Normally in Finder all these 3 devices show small Eject symbols/buttons for unmounting them correctly.
    But sometimes only one of the 3 devices has an Eject symbol, and it's not possible to eject the other two devices.
    (Only workaround to eject these two was via Disk Utility.)
    Why? How can I fix this? Thanks.

    Thanks for your answer.
    I question a company whose one  device shows up as three icons - one would think one icon per device would be sufficient?
    I found this a bit strange too... (But the camera - especially HD video - is really very good.)
    ... eject button in the toolbar...
    OK, I'll try this the next time the problem occurs and will report back.

  • Mount and unmount network drives

    Hello,
    I am trying to create an automated script to first unmount the network drives and then mount them to ensure no duplicates are created.  I'm not much of a scripter but i found that you can use the following command to properly mount the drive
    mount "smb://username:password@server/share"
    and it mounts it just fine, the issue is... I can't get the unmount portion to work.
    Can anyone shed some light?
    THANK YOU!!!

    I just tried doing:
    sudo unmount "smb://blahblahbalbh"
    it throws out a syntax error stating "expected "," but found identifier.  It highlighted the "unmount" portion.
    I am using automator to run applescript.  Any suggestions?  should I be going about this another way?
    @rccharles
    nothing is running from the mapped drives.  I am simply mounting them and then trying to unmount.  They are not even open.

  • Can't format cloned SSD that stopped booting in my MacBook Pro. Disk Utility always posts an error with mount and unmount issue. Any clues?

    Is there any way I can reformat a cloned SSD that was used to upgrade my original HDD?
    It suddenly stopped booting (a progress bar always appeared followed by a shutdown)
    I've tried to reformat the SSD via USB case, and using Disk Utility, but it keeps on send error message with unmounting issues.
    Any clues as how to overcome this problem?
    Thx
    Nuno

    Have you connected that drive to another computer and if you have can you do anything with it on the other computer. If not then the drive has failed.

  • Ipod 20gb photo mounts and unmounts quickly

    I'm having a problem trying to get my brand new (just opened it) ipod to work with my G5 DP1.8 powermac running 10.3.9.
    when i first plugged in the ipod, it initiallized as expected: asked me the 'do you want to sync automatically', etc. questions. and it sync'd.
    I prefer disk mode, so i also set that. and, i had to manually eject the ipod.
    now, i've had nothing but trouble. on more than several occasions i plug in the ipod and it briefly shows up in the 'source' list of iTunes for 1/2 a second and automatically ejects.
    so, i made a new playlist with about 20mb of song not on the ipod and that gave me time to look in the preferences while it synced. mysteriously, the 'disk mode' box was unchecked. so, i checked it again.
    even in disk mode, the ipod automatically ejected itself after the sync.
    when i plugged it in again it treated the ipod as new...asked me if i wanted to auto-sync with this computer. then, it told me there was not enough space on the ipod to hold the music on this computer AND what was on the ipod. so, i chose 'erase and sync' (or some message similar).
    it took 25 minutes to sync and auto ejected (with disk mode verified on).
    now, i'm back to square one. when i plug in the ipod it auto ejects 1/2 second after it appears in itunes.
    I cannot even restore the software as, the computer says no ipod is attached--or in the brief 1/2 second it is mounted presents a message that the (current) updater is not compatible with this ipod.
    I have also tried resetting the ipod.
    any suggestions?

    So, as a followup, I successfully got my misbehaving muic duo to work by doing the following:
    - as soon as the iPod is mounted, going into iPod options and selecting to automatically syncing one playlist
    - once completed, manually checking off one to five more, depending on how well things are going
    - it took about an hour, but things started working better as I went along, with the most I could load successfully at 500 songs.
    I hope this helps.

Maybe you are looking for

  • Second Monitor seen as "VGA Display"

    Has anyone seen this before? I have a Mac Pro 1,1 with 2 nvidia 7300 GTs, and three Acer x193w displays connected using VGA to DVI adapters. Only one of the monitors is recognized as a "x193w" with the second and third seen as "VGA Displays". The pri

  • CS2 Automate Web Photo Gallery causing photoshop to crash

    All attempts to use this function end in Photoshop crashing. Photoshop CS2 on OS10.5.4 - Imac 7,1 - 2.4 Ghz Anyone else experiencing this?

  • Where can I buy a Tecra A10

    I'm looking to replace my current M10 series laptop to the top of the range of Tecra A10 series. However, I cannot find a single online supplier that stock them. Does anyone know where I can buy one either from a shop or online for next day delivery

  • My safari keeps quiting what can i do?.

    my safari keeps quiting what can i do?.

  • Timeouts with RAS OpenDocument: CORBA Error reported

    I am trying to code a .net application using the Report Application Server in a Crystal Enterprise 10 environment.  My code so far is very simple: s = mgr.Logon("user", "pw", "server", "secEnterprise"); ReportAppFactory factory = (ReportAppFactory)s.