Shutdown, copy, start vhdx

I have read a dozen or so scripts to safely shutdown a vhdx, copy it to a local backup drive and restart the vhdx but none of them work, not one. Maybe my scenario is off but here is the foundation: host =MS server 2012 std 64bit, 2 x 128 ssd o/s, 2 x
1Tb data drives (one for backup), I have 2 vhdx's - 1=Active Directory running MS Server 2008 32bit and 2nd  running MS Server 2012 std 64bit for files and a sql express db (probably sql express 2008r2 or 2012). I need a powershell script (or any
other for that matter - have tried combination of ps1 & bat files) that will properly shut down the vhdx's (presently Drive H -Hyper-V), copy them to drive D -Backup and then restart the vhdx's. I would like this to run daily at a prescribed time
or realtime, do not want to merge files so differential out, need a notice or FILO to insure the backup does not utilize more space then what is available (delete previous version would be nice), and possibly send an email upon completion. Expected size of
AD = 60-80Gb, expected size of File/Db backup 400Gb. Size of hd = 1Tb for backup. Is there a way to do this or am I pipe dreaming and should I buy vhdx backup software / program and if so, any recomendations?

Brian, thanks for the response. Here is where I am currently at:
VMStartStop.ps1
# ---------- SCRIPT STARTS HERE--------------
$waitstart = 200
$waitshutdown = 120
if ($args[1] -match "0") {
$inputfile=get-content $args[0]
foreach ($guest in $inputfile) {
write-host "Starting $guest"
$vm = gwmi -namespace root\virtualization -query "select * from msvm_computersystem where elementname='$guest'"
 $result = $vm.requeststatechange(2)
if ($result.returnvalue -match "0") {
start-sleep -s $waitstart
write-host ""
write-host "$guest is started" -foregroundcolor green
write-host ""
else {
write-host ""
write-host "unable to start $guest" -foregroundcolor red
write-host ""
if ($args[1] -match "1") {
$inputfile=get-content $args[0]
foreach ($guest in $inputfile) {
write-host "shutting down $guest"
$vm = gwmi -namespace root\virtualization -query "select * from msvm_computersystem where elementname='$guest'"
 $vmname = $vm.name
$vmshut = gwmi -namespace root\virtualization -query "SELECT * FROM Msvm_ShutdownComponent WHERE SystemName='$vmname'"
 $result = $vmshut.InitiateShutdown("$true","no comment")
if ($result.returnvalue -match "0") {
start-sleep -s $waitshutdown
write-host ""
write-host "no error while shutting down $guest"
write-host "shutdown of $guest completed" -foregroundcolor green
write-host ""}
else {
write-host ""
write-host "unable to shutdown $guest" -foregroundcolor red
write-host ""
else {
write-host "USAGE: to shutdown VMs," -nonewline; write-host ".\managehyperV.ps1 c:\hosts.txt 1" -foregroundcolor yellow
 write-host "USAGE: to start VMs," -nonewline; write-host ".\managehyperV.ps1 c:\hosts.txt 0" -foregroundcolor yellow
# ---------- SCRIPT ENDS HERE--------------
hosts.txt
AD
OasysDB
(have also tried with AD.vhdx, OasysDB.vhdx)
BackupVHDX.bat
This is a simple cmd/batch file that calls Powershell with the VMStartStop.ps1 script file and passes the hosts.txt (list of virtual machines) and a single parameter that instructs the script to shutdown the virtual machine or start it up.
REM Hyper-V Virtual Machine Backup
REM Shutdown virtual machines
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe c:\Powershell\VMStartStop.ps1 c:\Powershell\Hosts.txt 1
REM Copy virtual machines, /Y overwrites the file if it already exists
copy /Y "D:\Virtual Hard Disks\V1\Virtual AD.vhdx" "\\computername\k$\Virtual Servers\V1\Virtual AD.vhdx"
 copy /Y "D:\Virtual Hard Disks\V2\Virtual OasysDB.vhdx" "\\computername\k$\Virtual Servers\V2\Virtual OasysDB.vhdx"
REM Start Up virtual machines
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe c:\Powershell\VMStartStop.ps1 c:\Powershell\Hosts.txt 0
REM Finished!
PowerShell set to: Unrestricted on CurrentUser & LocalMachine
when I run the bat file
in red: c:\Powershell\VMStartStop.ps1 : The Term 'c:\Powershell\VMStartStop.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program
At line:1 char:1
+ c:\Powershell\VMStartStop.ps1 c:\Powershell\Hosts.txt 1
     + CategoryInfo    :ObjectNotFound: <c:\Powershell\VMStartStop.ps1:String> [],
    CommandNotFoundException
     + FullyQualifiedErrorId : CommandNotFoundException
I am not a programmer and copied this from a blog, tried to massage it to fit without success. My host is MS Sver 2012std, my Virtuals are AD MS Svr 2008std 32bit, OasysDB MS Svr2012std 64 bit (for file and sql express). names in H:\Hyper-V\Virtual Hard
Disks /AD & OasysDB. I assumed they are .vhdx
I thought the script was / is to shut down the VM. Then copy the VM's over to a D:\ drive (backup)
Lets start here if you are willing as there are more details but one step at a time. If it is just issues with my code, and you are willing to troubleshoot, we can step into each issue / next issue as appears.
Thanks again in advance
Mrb53

Similar Messages

  • WebLogic Datasources : Automatically Shutdown and Start up

    Hi there,
    I have a problem with my datasources, I have WLST script which shutdown and start automatically some datasources in my environment, all of them in my crontab !
    Follow exactly my script !
    [weblogic@wls_server restartDS]$ cat shutdownDS1.py | more
    connect('weblogic','password','t3://server:10000')
    domainConfig()
    servers = cmo.getServers()
    domainRuntime()
    for server in servers:
    try:
    print 'check ' + server.getName()
    print '/ServerRuntimes/' + server.getName() + '/JDBCServiceRuntime/' + server.getName() + '/JDBCDataSourceRuntimeMBeans/MYDATASOURCE-XA1'
    cd('ServerRuntimes/' + server.getName() + '/JDBCServiceRuntime/' + server.getName() + '/JDBCDataSourceRuntimeMBeans/MYDATASOURCE-XA1')
    objectArray = jarray.array([], java.lang.Object)
    stringArray = jarray.array([], java.lang.String)
    invoke('shutdown', objectArray, stringArray)
    except WLSTException,e:
    print server.getName() + 'is not running.'
    for server in servers:
    try:
    print 'check ' + server.getName()
    print '/ServerRuntimes/' + server.getName() + '/JDBCServiceRuntime/' + server.getName() + '/JDBCDataSourceRuntimeMBeans/MYDATASOURCE-XA2'
    cd('ServerRuntimes/' + server.getName() + '/JDBCServiceRuntime/' + server.getName() + '/JDBCDataSourceRuntimeMBeans/MYDATASOURCE-XA2')
    objectArray = jarray.array([], java.lang.Object)
    stringArray = jarray.array([], java.lang.String)
    invoke('shutdown', objectArray, stringArray)
    except WLSTException,e:
    print server.getName() + 'is not running.'
    exit()
    Don´t worry, I have another script which kill XA3 and XA4 datasources as well, so, this way, I have load balancing here !
    It works with CRONTAB !
    The problem here is : Doesn´t matter if datasources are running or not, simply , datasources automatically shutdown and after that, start it! But I would like to improve this, I would like to implement datasource status condition, I mean, when datasource it become overloaded, it kill automatically , this way, I would not use crontab, but another kind of trigger |!
    Did you see this before ?
    I would like to improve this workaround !
    Just keep in mind, me and my team, didn´t discover the root cause yet, so, this automatically datasource restart is a kind of workaround!
    Thanks in advance !
    Edson

    Hmm. what was the problem app?
    Force a shut down by holding the power button for an extended amount.
    Reboot into SafeBoot mode to clear cache files, then reboot as normal.
    SafeBoot  http://support.apple.com/kb/HT1564

  • How to shutdown and start agent in ODI 11g in Linux Environment

    Hi Experts,
    Pls any one can help me on "How to shutdown and start agent in ODI 11g in Linux Environment" and where can I find Agent.sh and Agentshutdown.sh files location in ODI 11g and parallely how can I find Odiparameter.sh file location
    Thanks in Advance
    Regards
    Phani

    Phani ,
    Go to your <ODI_11g_HOME>/oracledi/agent/bin
    and you will find agent.sh , agent_<standalone_agent>.sh and odiparams.sh and other agent files.
    Step 1. Update your odiparams.sh
    Step 2. Create the Physical and Logical Agent int your Topology using the same port_number and name provide while creating the Stand alone agent during installation ( or) create accordingly the agent in Topology with name and port number as required and make the modification in agent_<stand_alone>.sh file
    Step 3. After doing so start your agent_<stand_alone>.sh
    Step 4. Repeat the process 2-3 for any number of stand alone agent created on different ports and steps 1 to 3 for different Work repository
    Thanks
    Dev

  • Forced or abrupt (crash etc) server shutdown detected, starting recovery

    Hi,
    I have encountered following error message in server.log of Oracle10gAS ver 10.1.2.0.2.
    "Forced or abrupt (crash etc) server shutdown detected, starting recovery process..."
    I got this message when I was pushing 1000 xml requests to a receiving servlet in Oracle10gAS Ver. 10.1.2.0.2. Out of 1000 requests, few of the request were not being reached to the receiving servlet. I amm hoping the problem would be becuase of the server being restarted automatically.
    Could anybody who had faced this problem help me out as this is a showstoper and needs to be resolved ASAP.

    hi chchang,
    Have you solved your problem? If so, please let me know the solution.
    Since im facing the same sort of problem. But in out case, the forced shutdown operation occurs frequently (within 10 -15 mins).
    Thanks in advance..
    regards,
    srinivas.M

  • I am having problems shutting down my MacBook Pro.  I go to the apple and click shutdown or restart, it appears the shutdown process starts, the screen goes blue and the little circle keeps going round and round, but nothing happens even after 30 minutes.

    I am having problems shutting down my MacBook Pro.  I go to the apple and click shutdown or restart, it appears the shutdown process starts, the screen goes blue and the little circle keeps going round and round, but nothing happens even after 30 minutes.

    Make sure you quit all your applications before shutting down.
    And try resetting the SMC.
    Intel-based Macs: Resetting the System Management Controller (SMC)

  • Copying start to TFTP-3122 bytes, sh run 4487 bytes

    Hi,
    Copying start to TFTP server shows 3122 bytes copied over, however a sh run provides an output of 4487 bytes. Is the discrepancy between the above memory volumes normal?

    Said
    I have checked on a couple of routers and they copy the same length when copying start or copying running. It looks to me as if changes were made in running-config that are not saved to startup-config.
    HTH
    Rick

  • Automatic Scheduling of Virtual Machine Shutdowns and Start-ups

    Is there a scheduler available to Shutdown and Start-up Azure Virtual Machines?

    Hi,
    Based on my experience, if you shut down the VM within the RDP session, the VM would be in the stopped status and you will still pay for it.
    Do you want to stop it to the stopped(deallocated) status to save money? If yes, you can create schedule tasks with Azure PowerShell cmdlets on your local computer.
    Start-AzureVM -ServiceName xxx -Name xxx
    Stop-AzureVM -ServiceName xxx -Name xxx (VMs would be in the stopped(dealloacted) status)
    Stop-AzureVM -ServiceName xxx -Name xxx -StayProvisioned (VMs would be in the stopped status)
    Please note that if all the VM in a cloud service are in the stopped(deallocated) status, the public IP address would be changed next time you start a VM.
    More information:
    How to install and configure Azure PowerShell
    Start and Stop Windows Azure Virtual Machines
    Best regards,
    Susie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Problems copying start up disk to Raptor drive? I'm in a mess here...!

    Hi, I'm hoping someone can help me with this quickly, I've got work deadlines approaching and my system's not working properly... aaagh!!
    (really wish I hadn't started on this plan now, but hey...)
    I'm trying to copy my startup disk from a 128 GB IDE HD (of which approx only 50GB is used), onto a 74GB SATA Raptor drive (running off a Sonnet PCI card).
    I want to move an exact copy of the used section (about 50Gb), so that I won't see any difference (except in speed!)... I've tried using Lacie Silverkeeper, and it boots ok, but doesn't seem to have saved all of the various prefs etc (eg. in Logic (6.4).
    If I make a clone, (Carbon Copy Cloner?) it'll be about 120Gb, which obviously won't fit on my Raptor. So what can I do??? (Can I get the Carbon Copy Clone onto a drive smaller than the clone itself?)
    Help please, this is stressing me out!!!!!!
    Thanks!
    G4 FW800 1GB/QS2001 1.25GB RAM, (OSX .3.3), iBook G4 (1.2ghz, 1GB RAM, OSX.3.5)   Mac OS X (10.3.3)   3 int.HDs, 3 Lacie ext.HDs, Logic Pro 6.4, RME Fireface 800. 4GB iPod Nano.

    Hi Vernon...
    Have you noticed any performance boost by switching
    to the SATA configuration.
    Well I'm running 1 SATA Raptor as boot drive, the other 2 HDDs are still ATAs. I have noticed that things seem to have picked up a bit, before things were certainly sluggish by comparison (not that it was deathly slow before). But I'd be a lot happier if it was more stable!
    My main issue with the MMD's is that that they seem
    to be very picky about upgrades. Anything you add
    can cause them to become unstable.
    As I'm discovering...
    Have you had similar problems in the past? And what was the solution?
    G4 FW800 1GB/QS2001 1.25GB RAM, (OSX .3.3), iBook G4 (1.2ghz, 1GB RAM, OSX.3.5)   Mac OS X (10.3.3)   3 int.HDs, 3 Lacie ext.HDs, Logic Pro 6.4, RME Fireface 800. 4GB iPod Nano.

  • IMac DV slot-loading power button glows orange after shutdown, cant start

    Hi,
    I have iMac DV SE (graphite model) of 1999, 320MB RAM, 40 GB HD, running Mac OS X 10.4.7.
    Everything seems to work fine, but when I go to Shutdown, it shuts down fine and power light goes off...Then several minutes later, the power button turns orange and stays like that for a few hours and then goes off again.... Then several hours later or the next day, I have a hard time getting it to turn on again by hitting the power button.. the keyboard (old iMac keyboard) power button never works to turn on the iMac (should it?) but when I hit it while in Mac OS X, it shows me the menu to shutdown, restart, sleep, etc...
    Also, by PRAM battery seems good (I measured it at 3.6 V) and it seems to keep track of the date and time just fine, so I cant imagine it's the battery....
    So in the past when this happens, it just keep hitting the power button and/or remove the power cord and re-insert, etc, and some combination of that after many tries the iMac finally starts up...
    Any idea what's going on? I cant find any discussion of the power button going orange after a shutdown and the fact that my keyboard power button doesnt work to turn on the Mac...
    Help...
    Andrew

    Ah.. very interesting... I'm surprised I couldnt find any info on the 'net about this orange power light...
    Anyways, I found have some interesting stuff since...
    1. On this last occasion when it didnt turn on, I was jiggling some stuff (plugging and unplugging the power cord several times.... then I tilted the iMac slightly and let it "drop" to jostle/jiggle it)... and after the slight "drop," I hit the power button and it turned on just fine... d'oh... I wonder if something's just "loose" somehow... I dont have a random shutdown problem, once it's turned on and inside Mac OS X, it works fine for hours and hours until I tell it to shutdown. hehehe...
    2. Just last night, before going to bed, I shut it down and since it's plugged into a power surge, I turned the power OFF to the power surge, so now it doesnt have any power to it... so this morning, I turned power to the power surge, and hit the power button on the Mac and it turned on just fine! d'oh again.. hehe... so it almost leads me to believe somehow that leaving the power cord with electricity flowing to the Mac when the Mac is shutdown is "hurting" it somehow, and if there is no power connected when it's shutdown, it works normally (I think)...
    Very strange indeed...
    Anyways, I got this Mac second hand so I am wondering if this was a problem for the original owner... when I first got it , I knew the hard drive was missing, so I put a 40GB IDE hard drive from a PC and formatted it, etc... so not sure if the hard drive could cause a boot issue...
    Oh, well, I guess I'll keep using this iMac until it no longer turns on.. lets see how long I can keep going like this ..heheh..
    Andrew

  • After upgrade to Mavericks shutdown with start button doesn't work

    Hallo!
    I have a MacBookPro 15"/ 2,66 GHz/ Intel i7 (before upgrade to Mavericks OS 10.9.x was installed):
    It was always possible to press the start button for about 1 second and this opened a popup where you could chosse "shut down", "sleep" or "cancle". After the upgrade to Mavericks this function doesn't work any more. When I press the start button the MBP goes into the sleep mode.
    Any idea what happened to this feature?
    Thanks

    The feature is still there, but the power button function changed with Mavericks to be like this:
    one-click = put the machine to sleep
    click and hold (3 secs) = display shutdown dialog box
    click and hold (10 secs) = hard power off

  • I was using skype. Every application was working, but I couldn't control any application. Somehow managed to shutdown and start. Please help

    I was using Skype, for more than an hour. I had safari running as well. All of a sudden Skype video got disconnected, then all applications started behaving strangely. I could not control any applications. System was acting strangely. Somehow managed to shutdown the system and restart. Please help

    Disconnect all peripherals from your computer.
    Boot from your install disc & run Repair Disk from the utility menu. To use the Install Mac OS X disc, insert the disc, and restart your computer while holding down the C key as it starts up.
    Select your language.
    Once on the desktop, select Utility in the menu bar.
    Select Disk Utility.
    Select the disk or volume in the list of disks and volumes, and then click First Aid.
    Click Repair Disk.
    Restart your computer when done.
    Repair permissions after you reach the desktop-http://support.apple.com/kb/HT2963 and restart your computer.
    Skype issues should be posted in their forums and reported to their tech support department. 

  • MacPro Won't restart - clicking noise - full shutdown and start OK

    I've been having this problem with my MacPro 1,1 for months. If I restart it will just hang there making a clicking noise until I hold the power button to force it to shutdown and then I can start it without any problem.
    Recently I had a complete hard drive failure and used Time Machine to restore onto a new hard disk. Now I have a problem where sometimes it just sits there with a folder with a question mark on it showing it can't find the drive to boot from. If I hold down the alt key then it shows my disk but calls it EFI Boot, not it's normal name of Macintosh HD, but then it can start up fine.
    So I'm not sure if I've got two problems or if my old problem just got worse, any other info I need to post to help diagnose the problem?

    "EFI" is cosmetic and can be result of using Disk Warrior for one. I think the trick is to reset Startup Disk off and back to the volume.
    And DO run Disk Warrior in addition to Apple DU to repair and rebuild the directory!

  • Icloud shutdown at starting

    I installed Icloud on my new windows 8.1 PC today and installation goes normaly. After restart, I enter info to login with Icloud and it always shutdown. I tried reinstallation, installation on another (exactly same model) PC and it's work, so I reinstalled Icloud, Itunes, Bonjour and also restored PC to previous restore point and reinstalled Icloud after...Always the same things happen!!! Need help!

    Have you run Repair Disk from your install DVD?
    Repair Disk:
    Steps for using Disk Utility
    1. Insert the Mac OS X Install disc or Install Disk 1 that came with your computer, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
    5. Select your Mac OS X volume.
    6. Click Repair.
    If you repair errors run it until no errors found.
    -mj

  • I am having a sudden shutdown during start up

    During the initial start up of my MacPro i am having a sudden shut down looks that the power has just been turned off. After trying again the same thing happens.
    Basically at the moment i cant start up the MacPro to see what is the problem.
    Does anyone have any ideas?

    The way to deal with it, assuming that the disk is indeed getting full - Get Info on the disk in Finder and see how much space it says it has - is to first see if you've emptied the Trash. If not, do so and see how much space that frees up.
    If that doesn't help the issue, then you'll have to remove documents. What documents you can remove is something only you can answer. There may be applications you've installed that you can remove, or movies that you don't need or can archive off to another disk, etc. A utility such as WhatSize or DaisyDisk can help you determine what's taking up all your storage space.
    Regards.

  • Dear All, I have to restart (Shutdown and Start) my MAC Outlook every time for new mails.

    Dear All,
    i have configured my office mail on MAC Outlook. I have some queries.
    1) I have to restart my Outlook after every 5 minutes to receive new mails. They are not pop up automatically.
    2) Every time i start outlook the bar (left side of my outlook in bottom) of sent and receive starts e.g: Retrieving (4/16000).How can i stop this to retrieving again and again.Even i can see my all 16000 mails in my outlook.
    3) The process of retrieving mails is very slow for example 4/16000 mails took almost 3 minutes.
    Please help me to resolve my problem.
    Your urgent reply will be highly appreciated.
    Thanks
    Adeel Imtiaz

    Dear Toocool4,
    Thank you for your reply.
    Its not exactly message 4 what i want to say is i can see my all 16000 mails in my outlook but every time when i star my outlook all this stats again.And secondly i am unable to receive my news mails until i restart my outlook.
    Thanks
    Adeel Imtiaz

Maybe you are looking for

  • Keep getting error message when trying to dowmload iso6 on my iPhone 4s

    Error message keeps coming up when I am trying to finish download of iso6 please someone help

  • Is it possible to use a MacBook Pro 9.1 with Snow Leopard

    Hallo, i tryed out to install a macbook pro 9,1 with Snow Leopard, but by loading the drivers he stops with booting. The version i try out is 10.6.8 and i tryed to boot from an extern drive also with 10.6.8 with the newest updates. I hope to get some

  • Files no longer default to SRGB after processing

    I still have the ICC profile box checked when ave a Jpeg after processing. Noticed that there was a bit of color shift on some images viewed on my web site in firefox---- checked the color space---unassigned!!  That usually only happened the check bo

  • Form Mail

    I have loaded form mail into my hosting account for juliashipley.com not sure which code to use don't need the ones that create a form so that leaves 2 a very short script which does not work and the other folder has a huge long script. Can someone p

  • Error ORABPEL-04040 & ORA-22990

    Hi, We are getting this particular error when we are placing an Order extracting error from log file *09/12/14 14:14:51 0 - ORABPEL-04040* Cannot update lob column. The process domain was unable to update the lob column "3" in the datastore. The exce