Removal of hardware store unwanted VM, while it is powered. -questions

So while trying to work/modify scripts already exist; to identify and "clean up if possible" unwanted material (series, USB, etc...) If some problems of type gotcha. * Previous scripts based on http://communities.vmware.com/thread/137257 - $VM. ReconfigVM_Task ($Spec)

If the target VM has unwanted devices that are only USB controllers, the script works with number (Script generated by Onyx.) It will remove the USB controllers if the virtual machine is powered power

Now, if I repeat this process and the virtual machine has some unwanted devices which include the USB controllers. Now I also include floppy, series and parallel, then the script error when I change to delete based on a list of "equipment" unwanted devices In this case, whether or not I jump on all the unwanted material that isn't USB. The error comes from the vCenter events, no powershell & task. I even used onyx to compare to remove the USB from the GUI and it has always had the same result.

Now it's the slightly modified version that I could use to achieve what I want, if it is not error on:

$NotWantedHardware = "USB|Parallel|Serial|Floppy"
$ConfigureVM=$true
$VMs = Get-VM $args[0]
    
Write-Host "Unwanted VM hardware Report & Remove."
foreach ($vmx in $VMs){
    $vUnwantedHw = @()
    $vmxv = $vmx | Get-View
    $vmxv.Config.Hardware.Device | where {$_.DeviceInfo.Label -match $NotWantedHardware} |  %{
        $myObj = "" | select Hardware, Key, RemoveDev
        $myObj.Hardware = $_.DeviceInfo.Label
        $myObj.Key = $_.Key
        if ($vmx.powerstate -notmatch "PoweredOn" -or $_.DeviceInfo.Label -match "USB"){$MyObj.RemoveDev = $true}
        else {$MyObj.RemoveDev = $false}
        $vUnwantedHw += $myObj | Sort Hardware
    }
    Write-Host "Here is $($VMX)'s unwanted hardware"
    $vUnwantedHw | Select Hardware, @{N="Can be Removed";E="RemoveDev"} | ft -AutoSize #Output for display        
    if($ConfigureVM){# Unwanted Hardware is configured for removal
        $i=0        
        $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
        foreach($dev in $vUnwantedHw){
            if($dev.RemoveDev -eq $true){
                $vmConfigSpec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec
                $vmConfigSpec.DeviceChange[$i].device = New-Object VMware.Vim.VirtualDevice
                $vmConfigSpec.DeviceChange[$i].device.key = $dev.Key
                $vmConfigSpec.DeviceChange[$i].operation = "remove"
                $i++
                $vmxv.ReconfigVM_Task($vmConfigSpec) #!#New Location, attempting to bypass error
                Write-Host "Removed $($dev.Hardware)"
            }
        }
#   $vmxv.ReconfigVM_Task($vmConfigSpec) #!#Old location, attempting to bypass error
    }# Unwanted Hardware is configured for removal
}

All are facing this problem, or should I just remove everything while his power, all in script?

I know the SDK Reference said you only need the Key property, but from experience I learned that it is apparently better pass the complete VirtualDevice object.

Try it like this

$NotWantedHardware = "USB|Parallel|Serial|Floppy" $ConfigureVM = $true $VMs = Get-VM $args[0]

Write-Host "Unwanted VM hardware Report & Remove." foreach ($vmx in $VMs){
  $vUnwantedHw = @()
  $vmxv = $vmx | Get-View  $vmxv.Config.Hardware.Device | where {$_.DeviceInfo.Label -match $NotWantedHardware} | %{
    $myObj = "" | select Hardware, Key, RemoveDev, Dev    $myObj.Hardware = $_.DeviceInfo.Label    $myObj.Key = $_.Key    $myObj.Dev = $_    if ($vmx.powerstate -notmatch "PoweredOn" -or $_.DeviceInfo.Label -match "USB"){$MyObj.RemoveDev = $true}
    else {$MyObj.RemoveDev = $false}
    $vUnwantedHw += $myObj | Sort Hardware  }
  Write-Host "Here is $($VMX)'s unwanted hardware"  $vUnwantedHw | Select Hardware, @{N="Can be Removed";E="RemoveDev"} | ft -AutoSize #Output for display
  if($ConfigureVM){# Unwanted Hardware is configured for removal
    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec    foreach($dev in $vUnwantedHw){
      if($dev.RemoveDev -eq $true){
        $vmConfigSpec.DeviceChange += New-Object VMware.Vim.VirtualDeviceConfigSpec        $vmConfigSpec.DeviceChange[-1].device = $dev.Dev        $vmConfigSpec.DeviceChange[-1].operation = "remove"        Write-Host "Removed $($dev.Hardware)"      }
    }
    $vmxv.ReconfigVM_Task($vmConfigSpec)
  }# Unwanted Hardware is configured for removal
}

Note that the index of-1 returns the last entry in a table in PowerShell, avoids having to make this variable $i :-)

Tags: VMware

Similar Questions

  • How can I remove my photos from my iPhone while keeping in iCloud? because I'm running out of space on my iPhone.

    How can I remove my photos from my iPhone while keeping in iCloud? because I'm running out of space on my iPhone.

    I want to keep all my photos in iCloud. I want to remove some of them from my iPhone 4 (IOS 8) in order to free up space on my iPhone. How can I do this? Thanks for help.

    With iCloud library enabled, you cannot delete a photo on a device (or iCloud.com) without deleting each device which uses iCloud photo library (iCloud.com). In order to save space on your mobile devices (and indeed your Mac if you want to) turn on the optimization of the pictures on these devices (settings > photos & camera > optimize storage on your mobile device and Photo preferences > optimize storage on your Mac)

    Dynamic optimization, it reduces the resolution of your photos, if necessary, so that you don't notice it occurring initially. However, when necessary, it is very effective, and users have reported libraries being optimized for much less than 10% of their original size in some cases. My own library is about 9% of its original on my phone size.

  • Can I remove this data store?

    Hello guys,.

    I free up space in a storage, and for that to work correctly, I followed the following steps:

    1. I created a new data store in other containers for storage.

    2 - I did a migration of storage of the old data store to the new.

    3 - remove the old VMDATA.

    At this point, I glued, because the old data store is not empty... West a strange folder inside, but I don't know if I can remove it, as you can see in the image below.

    VMDATA.GIF

    The question is: can I remove this data store? The showing on the photo, UID is the same UID of the LUN I want deleted.

    I use VMWARE ESXi 5.1 Enterprise Edition Plus.

    Kind regards

    Roberto

    files and folder in dotted lines are normally for the metadata of the data store itself.

    so, you can delete the data without any problem store.

    BTW. If you delete a data store and it is still used by a virtual machine the delet-job will be cancelled. There is a small security bit set

  • Cannot remove vSphere HA stuff to remove a data store

    Hello

    I am trying to remove a data store, but it is impossible to delete the HA heartbeat, and they are not deleted it I put my favorite heartbeat data for other stores of data warehouses in the cluster.  Any suggestions?

    Thank you!

    NYSteve

    Have you read this KB? http://KB.VMware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalID=2055137

    You basically have vCenter Server 5.1 patch 1 installed? If not, and you want to upgrade to work around this problem, disable vSphere HA for Cluster parameters, delete the affected data store and then reactivate vSphere HA.

  • How to remove a data store abandoned?

    Hello! I am the systems administrator for my organization where we have HP P6300 storage attached to our cluster of ESXi5. Usually, if we need a new Vdisk to any virtual computer, we create a new vdisk in storage and add them as a new data store in Vsphere, then we create the file within this new data store vmdk. I had to remove a disk of a virtual server. The steps are as below:

    1 remove the data from the drive

    2. remove the disk from the virtual machine and delete the vmdk file

    3 remove the data from the cluster of data store store

    4. remove the data store

    5 remove the vCenter store data (inventory------Clusters data store and data warehouses-right click on the data store and delete)

    6 - anyone the vdisk to ESXi hosts

    7 remove the vdisk to Storage Manager.

    But I made a mistake and missed the STEP n ° 4 and 5.

    Now I see the attached message whenever I'm trying to remove it. Guidelines for this problem and remove this missing data store in the vCenter?

    Thank you

    Ali

    OK, you have a way of death. The only way to fix it must restart the host.

    Kind regards

    Julien

  • Remove a data store

    I need to remove a data store so that I can reformat vmfs3 to vmfs5. It is my understanding that vcenter will not introduce any APD or correct payday loans? The LUN will remain visible to all guests, as I said I just need to remove the data store on this subject, so I can recreate it with vmfs5.

    I guess after I remove it, I should questions some hosts renumerisations (except done automatically vcenter) before I recreate?

    Thank you.

    You are right, since you don't anyone the LUN, there is no problem with ODA...

    Simply remove the data store and create a new one. After that you can rescan all hosts so that they detect the new format.

    André

  • Could not start the new virtual machine or VM remove a data store

    Hi guys,.

    I'm not new with ESXi, but my knowledge with vCenter and Clustering must be improved, so here's my problem.

    We have a Cluster of 2 ESXi 4.1 hosts on a San with 2 VMFS.

    My first problem is when I created a new virtual machine and try to start it, I got an error message similar to the one included with this post.

    My Second problem is more picky. Since I am unable to start my new virtual machine, I had removed from drive and I had created a new. But when I took a peek in the data store where was deleted VM, the directory with all the files are still there. When I try to delete it, I got an error message telling me that it is impossible to proceed.

    Q please?

    Best regards

    Stéphane

    82% of failure can be other issues.  The article below

    http://KB.VMware.com/kb/1006052

    Also, I saw, where bad records DB for your ESXi hosts can cause weird problems as well.  The host with the problematic guest, can you do a right click on it and "disconnect"?  Try to get out of the bunch at the data center level.  If you get an error vCenter, that means return folder DB.  From there, while the host is in a disconnected state, remove the host to vCenter, then "add host". This will update the DB record.  Maybe worth it?

  • Cannot remove the data store in esxi 3.5 - can help you

    OK - I have a problem. I messed up and now I'm stuck.

    I was "apparently" in the middle of a converter working, and I deleted the comments of esxi3.5, while the converter still worked.

    I selected the rafale and made a removal of the disc that worked, however the structure of associated file (windows 2000 Server) for this guest has not been deleted, so I chose my data store (datastore1) and - do you have a store of navigation data and when I try to delete the folder associated with the guest, I deleted I get the following error :

    "General failure caused by file" (with a "/" on the next line) and all I can do at this point is to click OK box to acknowledge the error and I can't delete the folder. I can't rename it either.

    I don't know how to get rid of it. I tried to create a new client with the same name as the folder and delete the comments again, but that does not work either.

    I'm really stuck - I'm afraid to go into maintenance mode because I have no idea what I'm going to be confronted here since I never used the maintenance mode.

    any help or ideas would be really appreciated.

    You can try to do a refresh of the data store. The folder structure is not re read very often. In the data store Navigator, click the folder root on the left side and click on the Refresh button.

  • Remove the new apple unwanted

    How can I adapt the news of apple to not show of sports entertainment and other categories that I care about anything?

    He is so busy, I click on even more. Thank you!

    Greetings, Umaiyo.

    Thank you for using communities of Apple Support. I know that in my busy life, I don't like being disturbed by news I deem important to me as well. I'll be happy to help you to carve out of the application of new topic or channels until you are interested.

    Use the news on your iPhone, iPad or iPod touch

    Remove a theme or a channel

    1. Go to your Favorites.
    2. Tap on edit.
    3. Press 'X' in the upper right corner of the string or the topic you want to delete.

    You can also cut a channel to prevent the stories to appear in your feed you.

    Dislike, silent or report a story

    Don't want to see certain types of stories in your feed you? You can mark the stories that you don't like, mute channels they appear in and tell stories. Drag right on the history or tap the Share button, then on your choice:

    • Tap aversion to cease to see similar stories in your feed you.
    • Press Mute channel in order to prevent the stories of a channel to appear in For You.
    • Tap the report to report a problem with a story.

    Your stream for you cannot update immediately when you don't like a story or cut a channel.

    Good reading!

  • C670-105 satellite unwanted reboot while playing a game

    Hello

    I had the same problem in the previous months, when I'm playing Football Manager 2011 on my Toshiba laptop.

    The game requires a lot of CPU at some point (when I move forward step, CPU and game create other teams results and create new next and so on) and it breaks after 1-2 hours of play.

    It gets stronger and stronger and that's it!
    PC automathically restart and I lost my time!

    It could be overheating CPU, but I get this problems only by playing this game.
    I can't forget to play while listening to the music from Youtube or any other source or Skype chat in the background, it remains only for a few minutes then it will restart the PC again and again.

    Who is wrong? Overheating or something else?
    Maybe I just need to reinstall any Windows or game (FM 2011)?

    I use: Toshiba C670-105 / Cor Intel i3 2.53 GHz, 4 GB RAM, Win 7 Home Premium 64-bit SP1, 300 GB drive HARD, DirectX10, NVIDIA GeForce 315 M

    My backup is currently approximately 180 MB. And of course, my laptop is above the minimum requirements to play this game.

    Any tips?

    > Whats wrong? Overheating or something else?
    Well, I think that nobody would be able to say exactly why the device stops without any further investigation.
    Usually the laptop could power OFF due to high temperature and high temperature is mainly the reason of downs stop unwanted automatic.

    Never clean the laptop s cooling fans in the past?
    No.? Probably dust and debris inside the cooling modules prevent the fans to run with the best performance and cause high temperatures, leading to the closing down.

    I recommend you to use a jet of compressed air to get rid of the dust. But sometimes these cooling modules should be cleaned professionally.
    But try first of the jet of compressed air.

  • My CD-ROM/DVD-rom material is able to burn, but I can't read the discs of the hardware store.

    I have used this support of Microsoft, but I can't go any further after using "Fixit" or "regedit" edition

    http://support.Microsoft.com/kb/929461/en-us

    Hello

    You have disk problems as the CD/DVD is actually 4 discs in 1 case (CD & DVD burning and)
    Playback of CD and DVD). So it is not unusual for parts from 1 or 2 to not work so that others do
    correctly.

    A CD/DVD cleaner 'could' help.

    CD/DVDs have a tolerance + - and your can read/write on the edge outside these discs
    tolerances. They may be delivered, but it is generally more economical to replace the disk.

    Several good info here:
    http://Club.myce.com/

    CD/DVD units
    http://www.myce.com/storage/

    Notes on the troubleshooting and repair of readers of compact disks and CD-ROM Drives
    http://www.repairfaq.org/repair/F_cdfaq7.html#CDFAQ_014

    ===========================================

    This troubleshooting could not help if there is alignment and/or wear issues however it
    a shot.

    Step 1: Please do all the same underneath if you did some before as is often total
    a process that solves the problem.

    Try this - Panel - Device Manager - CD/DVD - double click on the device - driver tab.
    Click on update drivers (this will probably do nothing) - RIGHT click ON the drive - uninstall.
    RESTART this will refresh the default driver stack. Even if the reader does not appear to continue
    below.

    Then, work your way through these - don't forget the drive might be bad, could be a coward
    cable or slight corrosion on the contacts (usually for a laptop) and other issues.

    Your CD or DVD drive is missing or is not recognized by Windows or other programs
    http://support.microsoft.com/kb/314060 - a Mr Fixit

    Try this fix manually if the Fixit 314060 does not work
    http://www.pchell.com/hardware/cd_drive_error_code_39.shtml

    Your CD or DVD drive is missing or is not recognized by Windows or other programs-
    a Mr Fixit
    http://support.Microsoft.com/kb/982116

    The CD drive or the DVD drive does not work as expected on a computer that you upgraded to
    for Windows Vista
    http://support.Microsoft.com/kb/929461

    When you insert a CD or a DVD, Windows Vista may not recognize the disc
    http://support.Microsoft.com/kb/939052

    Your CD or DVD drive cannot read or write media - A Mr Fixit
    http://support.Microsoft.com/GP/cd_dvd_drive_problems

    CD/DVD drive does not appear in Windows Vista, or you receive this error in Windows
    Vista installation after booting from the DVD (AHCI)
    http://support.Microsoft.com/kb/952951
    Drive CD - R or CD - RW Drive is not recognized as a recordable device
    http://support.Microsoft.com/kb/316529/

    Hardware devices not detected or not working - A Mr Fixit
    http://support.Microsoft.com/GP/hardware_device_problems

    Another possibility is that the cables are loose. Remove ALL power, then make sure that the cables in both
    ends. Remove and replace, do not just tight. For laptops, you can often clean power and
    contacts data with a pencil eraser.

    Some DVD players do not use the Windows default drivers so check with the manufacturer of system and
    manufacturer of device to see if there is a firmware or drivers for your drive if necessary.

    ===============================

    Step 2: You have disc problems as the CD/DVD is actually 4 discs in 1 case (CD & DVD
    Burn and CD and DVD read). So it is not unusual for 1 or 2 operational so that other parts
    do it right.

    Did you follow the Troubleshooting Guide for the reader who still does not work? There are
    the entries in registry that the troubleshooter does not solve and those who "might" be the cause.

    Check with your Maker system and a device for the two possible firmware updates and
    the correct registry entries for your car.

    Here are the keys that I of course are those in question - for the subkeys of the CD/DVD drive
    as there will be other subkeys in these keys. Do not forget to ask specific keys involved as well as
    the parameters.

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\System\CurrentControlSet\Enum\IDE

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\ {4D36E965-E325-11CE-BFC1-08002BE10318}

    -----------------------------------------------------------------------

    You can probably find more info here and maybe even the exact registry for your CD/DVD settings
    drive from someone with the same model.

    Forums - a lot of expert real help
    http://Club.myce.com/

    CD/DVD units
    http://www.myce.com/storage/

    Use DevManView to locate the CD/DVD in the registry (be careful and do a prior Restore Point)
    nothing change) - find the DevManView device and then make a right click on it free in RegEdit.

    DevManView - free - an alternative to the standard Windows Device Manager, which displays all the
    devices and their properties in flat table, instead of the tree viewer
    http://www.NirSoft.NET/utils/device_manager_view.html

    I hope this helps.

    Rob Brown - Microsoft MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • remove the hardware button does not

    Hello. I have windows 7 32-bit company. When I try to click on the green arrow on my screen, that 'remove hardware safely', it doesn't do anything, so I just plug into my USB stick without safe removal.

    Can someone help me solve this button?


    Thank you

    At the allways PC behaved this way, or that occurred after an update?

    If a brand PC or laptop, if you visit this site for decision makers and select your model and update the chipset drivers is that assistance?

    If a generic PC motherboard for the driver site

  • I think I've removed the app store. How can I reinstall it?

    I have removed the store. Can't find it. How doi I reinstall?

    wtflee answered the
    Well, I found the answer.  I know that other people are struggling too, so here is how to fix this problem;

    1. go to: http://www.jniesen.de/?p=490
    2. download the .zip at the end file containing three .lnk files.
    3. copy the file "Windows Store.lnk" to "C:\Program Data\Microsoft\Windows\Start run\programs".  It is a hidden folder, so make sure you can see hidden files (above, click on 'view' and check the box for hidden items).
    4. go to your menu of Metro and it should be there.  Works perfectly for me.
    I don't know why none of the mods had this response or even acknowledged that it was a problem to play.  But if you are away from your store, the fix above.
  • Remove the Windows Store Apps

    My question is about removing apps from the store of Windows 8.  It is apparently a "characteristic" of Windows 8, that we are not allowed to delete permanently 'Your applications' all or part of the lousy applications that we already have installed in the Windows store, although they later have been uninstalled from the PC.

    Is the only way, that's why, in order to purge the history is to refresh Win8 installed, then create a completely new online ID of Windows or use a local account?

    Thanks in advance!

    -Scott

    Hi Scott,.

    By design, we are not able to remove applications from your applications. To work around the problem, you can create a new Microsoft Account (using a different email ID) or a local account.

    Hope this information helps. If you need more assistance or information on this question, reply to this post. I'll be happy to help you.

  • Safely remove a data store

    I need to remove for good 2 data stores.  I first clicked each guest vm using these data storages and delete selected.  Data warehouses now show as empty when he is gone.  Can I just to right click\delete each empty data warehouses?  I would like to delete the corresponding LUN on the SAN (VNX) as the last step.  Can someone verify that it's correct.  I remember having a problem with this some time ago.  vCenter is version 5 - ESX 4.0 U2.  Thank you.

    The procedure will be the same for 4.x, then Yes, there will be some host commands involved. It seems really involved, but it really isn't so bad. Much better than potential wickedness that could come to remove them is not the right way.

Maybe you are looking for