Clean Way To Prevent Signature Collision Of Mounting VHDX In Parallel PowerShell Scripting

I have multiple Virtual Machines I am to build from a Sysprepped VHDX. (All this is done automatically via Powershell)
For each of these Virtual Machines, I copy this VHDX and create a new one unique to the Virtual Machine. However, I wish to mount each one (in parallel) and make modifications before attaching it to the virtual machine and booting the first time. 
The issue comes when it is time to mount the VHDX on the Physical Host, and these two processes attempt to mount at the same time. This causes a Signature Collision. I am looking for a clean - emphasis on clean - way to prevent signature collision. I have
tried the following.
Using the Get-Drive cmdlet and determining if one exist with a FriendlyName of "Microsoft Virtual Disk" before mounting, to detect if another VHDX is already mounted and waiting til it dismounts - the latency in this flag being available causes
this method to fail and still the two VHDXs attempt to mount and have signature collision, breaking the script associated with that VHDX.
I have tried using a Flag file, i.e., a text file to denote if a VHD is mounted and do a similar check - however, this relies on the file system and seems too clumsy for me. 
I have considered Environment variables, but am afraid this is also too convoluted for such a simple task.
Any recommendations? 

The builds are being done in separate scripts. The purpose is that each script can be ran on it's own to rebuild a particular VM, but when the host is first built, all scripts are run concurrently to build each VM (total of 3). They could be ran sequentially,
but the copy of the VHDX will make this take a very long time (or at least that is the thought, haven't really tested this.) The script is the same for all three builds just differentiates based on a parameter passed.
I am currently testing the inclusion of a PauseBeforeMount parameter, which I will pass to one of the two servers in question. This way, it will only be used in the full host build, and not if a single VM is being rebuilt.
     if($PauseBeforeMount.IsPresent){ 
           Write-Host "Pausing for VHDX Mount..."
           Start-Sleep -Seconds 60 
    #Mounts the OS Disk and captures the Drive Letter 
    Write-Host "Mounting OS VHDX located at $OS_VhdPath"
    [string]$OsDriveLetter = Mount-VHD -Path $OS_VhdPath -Passthru | Get-Disk | Get-Partition | Get-Volume | `
        Where-Object {$_.FileSystemLabel -eq "OS_Disk"} | Select -ExpandProperty DriveLetter
    $OsDriveLetter += ":"
 

Similar Messages

  • Is there any way to prevent or clean finger grease stains in your keyboard?

    As all of you might know, the body releases toxins (including body grease) through our fingers, and i notice even though im a clean person and i clean my macbook often i get some stains in the keys i ust the most, that being the command key, spacebar plus the whole asdf jkl; line of th ekeyaboard, how can i get them off!?

    Is there any way to prevent...grease stains in your keyboard?
    wear gloves?
    how can i get them off!?
    Try a Mr. Clean Magic Eraser

  • Is there a way to prevent psd from being the default file extension?

    In previous versions, psd was added automatically if the document was layered. Since I don't use psd, I had to manually change to tiff.
    But I'm finding that even flat (unlayered) files that came in as jpgs have psd inserted as the default. I would have thought that, by default, a file could stay whatever it started out being. (Whether jpg or tiff, flat or layered).
    This happens when I "save as" even when I don't change the name of the file, only save it in a different location (such as a jpg file from a flashcard being saved to computer).
    Is there a way to prevent the extra step of rejecting psd? Is there a preference or something I have missed?

    Although the little camera I was using doesn't capture 16 bit, I did run the jpgs briefly through ACR to try out the shadows/highlight feature since the photos were perfect candidates. My preference there is to convert to 16 bit ProPhoto so maybe--even though the files opened as jpgs. That might be the problem: maybe bit depth is the trigger for psd assignment. Still, I wish there was a way to disable it.

  • I allow my grandchildren to play free games on my ipad that I download for them.  Is there a way to prevent them from accidentally (or otherwise) purchasing upgrades?  My 6 yr old just did so and has no idea how she did it.  Can I block this access?

    I allow my grandchildren to play free games on my ipad and iphone that I download for them.  Is there a way to prevent them from accidentally (or otherwise) purchasing upgrades?  My 6 yr old just did so and has no idea how she did it. Is there a setting that would prevent this from happening?

    Yes.  You can set restrictions.
    This is covered in the manual.
    iPhone User Guide (For iOS 5.0 Software)
    iPad User Guide (For iOS 5.0 Software)

  • Is there any way to prevent the OS from querying the Superdrive when start

    Just a random question. Whenever my MacBook Pro starts up (either from sleep or a complete/fresh start, the OS queries the drive slot to see if there is a disc present. While this may be normal behavior, it seems to slow down the start up process. (I rarely ever have a disc in the drive). Just curious if this, in fact, normal, or if there's something awry.

    Is there any way to prevent the OS from querying the Superdrive when start
    No
    he OS queries the drive slot to see if there is a disc present.
    How can you tell? Based on the noise it makes?

  • I don't want my Facebook Contacts added to my iphone Contacts as a result of this new update.  Is there a way to prevent that from happening?

    I've been told that when I apply the latest update issued by APPLE, it will add all my Facebook Friends into my Contacts on my iPhone.  Is there a way to prevent that from happening?

    Unfortunately when upgrading to iOS 6 the setting to add Facebook Contacts to your Contacts app is on by default. But once the upgrade is complete you can go to:
    Settings > Facebook > and turn off Contacts.
    That will get rid of the Facebook stuff showing up in your Contacts app.
    BTW, I also turned off Calendar on my iPhone and iPad so that Facebook events and Friend's birthdays etc. will not show in my Calendar app.

  • When I save photos or videos from my iPhone 4S to my PC they are all sideways.  Is there a way to prevent this from happening?  All are taking with the phone in portrait mode.

    When I save photos or videos from my iPhone 4S to my PC they are all sideways.  Is there a way to prevent this from happening?  All are taken with the phone in portrait mode.

    Shot videos ONLY in landscape. For photos choose what's you like. Maybe you have to rotate photos on PC. What's your operating system?

  • I'm trying to add a playlist manually to my iPhone 4. It won't let me because it's trying to delete all of the music currently on my iPhone. Is there any way to prevent this from happening in order to start manually updating it?

    I'm trying to add a playlist manually to my iPhone 4. It won't let me because it's trying to delete all of the music currently on my iPhone. Is there any way to prevent this from happening in order to start manually updating it?

    Are you leaving the box unchecked to Manually manage music & videos? You don't need to to add anything to the iPhone.
    Simply drag the playlist to the iPhone to manually add it.

  • Is there a way to prevent actions, like spaces, to only occur on one screen when using multiple monitors?, Is there a way to prevent actions, like spaces, to only occur on one screen when using multiple monitors?

    Hello, I am using my Macbook Pro, late 2012 with a second monitor, which is a TV. I am wondering if there is a way to prevent spaces from poping up in the second monitor when i want it to ocur in the primary monitor? So on one monitor, or whichever one the mouse is, I want say Spaces, or Launch pad to popup on and not interfer with the other screen. Is there a way to do this?
    Thanks,
    Harrison Howard

    I believe the answer is no.
    I have not been able to make extra monitors stick with a particular space.
    Also, there is a relevant discussion here regarding this matter.
    The last poster suggests a workaround which does not work as far as I can tell.
    Here is the discussion thread
    Best of luck

  • I have an iPad 2, and I am sending PDF file to my iPad, via a Hotmail email. But, the PDF arrives to the iPad in Mail already opended, as a picture on the bottom of the email. Is there a way to prevent it from auto open, so I can open with iBooks instead?

    I have an iPad 2, and I am sending PDF files to my iPad, via a Hotmail account. But, the PDF arrives to the iPad Mail account already opened at the bottom of the email. Is there a way to prevent this auto-opening of the PDF. I've seen screen shots with the box, and PDF listed inside the box, but mine open automatically. I want to get them into iBooks...?

    I am having the same problem and it is even bigger.
    When opening a 1-page PDF in iBooks and sending it via mail it is sent inline as preview, but the recipient cannot open the file anymore. Also on iPad and iPhone there is no "open in" possible.
    Somehow the mail app does destroy the file. What is going wrong?

  • Is there a way to prevent people from downloading under your Apple ID?

    Is there a way to prevent strangers from downloading content under my Apple ID? Don't they need to know my password or security answers to download an app?

    Don't give them your password.

  • Is there a way to prevent an account with no administrative rights to install firefox to their local profile on Windows XP?

    Our users are normally not allowed to install any programs since their user accounts do not have administrative rights to their pc's. Has this been a feature in FireFox before?
    We noticed that one user was able to simply download firefox, run the installation setup, and the setup would default to install firefox under their local desktop profile instead of the usual c:\Program Files folder.
    ie. c:\Documents and Settings\userid\Local Settings\Application Data\Mozilla Firefox\
    Is there a way to prevent this from happening? We do not want to allow our users to be able to install any programs without our knowledge.

    The Skype add-in was the culprit in my case. Disabling it fixed the problem. As soon as I enable it, the problem comes back.

  • Is there a way to prevent iTunes from automatically starting the next playlist file on the iPad?

    Is there a way to prevent iTunes from automatically starting the next playlist file on the iPad?

    When you connect the device open iTunes and select it from the sidebar. Click on the Summary tab in the main window. Uncheck the option to automatically connect to iTunes. You will find it in the collection of options near the lower part of the window.

  • Is there a way to prevent a PDF file from being forwarded?

    is there a way to prevent a PDF file from being forwarded? For example, im a personal trainer and if i send a client a plan via PDF file, i want to make sure that they cannot send it to anyone else. I read about how you can secure a file by creating an ID and then having the recipient create an ID as well, but i would like to make the orocess as easy as possible for my clients and not have to have them create an ID and then send it to me. is there a better way to block the recipient from resending the PDF?

    Hi Kiana,
    As such there is no option to prevent the recipients from forwarding the pdf. However you can refer to this blog How do I prevent someone from forwarding a PDF?, it might be of some help.
    Regards,
    Aadesh

  • Is there any way to prevent iTunes from making duplicates of all my tunes?

    I've a repeating problem that iTunes duplicates my music files every time I open it. After it had made duplicates (and triplicates) of every tune, I blew away the library, went through my music folder and got rid of all the dupe files, and reimported it into iTunes. I haven't used iTunes since, but when I opened it today to start rebuilding my playlists, it is again making dupes of my files. When I open it, it says it is "Updating iTunes library...', and after it finishes there are more copies of files already there.
    Any way to prevent this?

    Yes the 2 main ways are with an ipod and external drive. Apple covers doing it with an ipod but you can follow the same steps, just skip afew http://docs.info.apple.com/article.html?artnum=300173

Maybe you are looking for