Removal of all media in cd players that target a data store

I'm trying to write a script where I pick up all the virtual machines that have an image in the cd player, the points in a given data store to and then removes the media.

That's what I came with, and I think it will work.

$datastore = "iso" # Datastore that will be removed
Get-VM | where{$_ | Get-CDDrive | where{$_.IsoPath -match $datastore }} | Export-Csv drive.csv #Gets a list of all VMs with CDs attached to that datastore
$egress = Import-Csv ".\drive.csv"
foreach ($_.Name in $egress) {
Get-VM -Name $_.Name | Get-CDDrive | Set-Cddrive -NoMedia} #Removes all media in cd-drives 

I feel like I cheated by exporting to a csv file, but when I tried to do a ' | '. "Select the name of ' the value I got was something like ' @{Name = XYZ}".

Any advice on how I could clean it or make it more effective?

Hello

Welcome to the VMware communities.

The following script is a purified your script version:

$datastore = "iso" # Datastore that will be removed
Get-VM | Get-CDDrive | where {$_.IsoPath -match $datastore } | Set-Cddrive -NoMedia

Best regards, Robert

Tags: VMware

Similar Questions

  • Get all the VMS in givencluster on the specific data store

    Hello

    I need help, filtering of all virtual machines in a given Cluster, which are located on specific data warehouses. I go so far:

    List of all the virtual machines in a given cluster:

    Get-Cluster CLUSTER-TEST | Get - VM

    List all the virtual machines on given data warehouses:

    Get - VM - data store 'TEST-DATA store.

    But when I try to combine these I still have all the virtual machines (also other clusters) on this data store:

    Get-Cluster CLUSTER-TEST | Get - VM - data store 'TEST-DATA store.

    I also found this command:

    Get-Cluster CLUSTER-TEST | Get - VM | % {@{$_ .name = $_.datastoreidlist | %{(get-View-propriété Name-Id $_).}} Name}}}

    It lists data warehouses for all the virtual machines in the given cluster. Now, I need that filter down to a specific data store.

    I need assistance with anyway =)

    With a nested Where clause and some not-so-nice trick PS it seems to work

    $ds = Get-Datastore Test* | %{$_.ExtensionData.MoRef}
    
    Get-Cluster Test-Cluster | Get-VM |
    where {$vm = $_; $ds | where {$vm.DatastoreIdList -contains $_}}
    
  • How to list all files within a data store and sent an email...

    Hello

    I know that within a data store there of are VM, but these virtual machines are right files?

    Some might create a virtual machine, remove the inventory but do not delete the folder/VM from the data store.

    Is thre anyway to get a script to list all records, not VM. s within a data store and be able to send emails?

    Thanks for your help,

    How about something like this:

    $VIServer = "YourVIServer".

    $EmailFrom = "Sender@Email".

    $EmailTo = "Recipient@Email".

    $Subject = "email subject".

    $SMTPServer = "YourSMTPServer".

    SE connect-VIServer $VIServer

    $datastores = get-Datastore

    {Foreach ($datastore to $datastores)

    $msg = "' nFolders in Datatore:"+ $datastore. " Name + "' not n".

    New-PSDrive-location $datastore - PSProvider data store name - VimDatastore-root '-' | Out-Null

    $folders = get-ChildItem Datastore:------|? {$_. ItemType - eq "File"}

    Remove-PSDrive Datastore. Out-Null

    {Foreach ($folder in $folders)

    $msg = "' t ' + $folder. Name + "' n '.

    }

    }

    Send-MailMessage-to $EmailTo - of $EmailFrom - $msg - SmtpServer $SMTPServer body-subject $Subject

    Disconnect-VIServer-confirm: $false

    This will send an email with an output similar to the following:

    Files in Datatore: local-esx100

    Test-VM

    ARandomFolder

    MoreFolders

    Files in Datatore: local-esx101

    Test-VM2

  • Mounting external USB HDD to host copy all the s vm to the local data store

    I have a scripted ESXi installation that works very well, but once the installation is completed I want to copy all the VM from a disk external DRIVE to store data on the host computer.

    There is no attached servers/clients, so it must be done from the host itself.

    in thele/var/log/usb.log file on the hard drive is recognized, but how to access and copy all the external HARD disc VM in the data store?

    install vmware tools

    _________________________________
    Good luck!

  • Cancel an increase in data store on removable hard drive

    Hello, I was just wondering, but I was messing around trying to find the way on an empty stomach for manually copying the VM to a RDX removable hard drive and decided to try to increase the size of the data with the RDX hard disk store.  I was wondering if there is a way to cancel this increase in size of the data store.  When I remove the RDX drive, it gives me an error saying no data store has been created but still work in the VM.  Any help would be appreciated.

    Welcome to the community,

    I understand thi correctly. You have added the RDX as a measure for the data store local drive!

    There is no way to remove a measure. You will need to evacuate the data store (i.e. save virtual machines), remove the extended data store and create a new.

    André

    BTW: With product (edition/version/version) are you using?

  • When I have a group of emails that I want to delete, what should I do to remove them all together in a single action, rather than having to delete them individually?

    Original title: I HAVE WINDOWS LIVE MAIL, HOW to REMOVE SPAM IN a SINGLE ACTION?

    When I have a group of emails that I want to delete, what should I do to remove them all together in a single action, rather than having to delete them individually?

    Hope you can help.

    Terry.

    Use CTRL - A or editing. Select all and then press the delete key.   Issues for Windows Live Mail must be addressed here: www.windowslivehelp.com

    Steve

  • My mouse no longer works 2 days ago... I restored my pc on the eve, it works... but that did not help my mouse. This mouse works on another pc... I am getting error usb? I removed & charged all under the usb tab__

    My mouse no longer works 2 days ago... I restored my pc on the eve, it works... but that did not help my mouse.   This mouse works on another pc... I am getting error usb?  I removed & charged all the usb tab

    Hello

    You may need assistance from a real store tech computer (no leeks and glances at a BestBuy or)
    other BigBox stores) or the manufacturer of your system Support.

    What is the error of USB?

    Follow these steps to remove corruption and missing/damaged file system repair or replacement.

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe)
    program generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Then, run checkdisk - schedule it to run at next boot, then apply OK your way out, then restart.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

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

    Please make these now even though you might have tried this before:

    Remove the mouse if indicated in the Manager of devices - devices of score - click right on - UNINSTALL.

    Then lets refresh the USB stack

    Control Panel right CLICK on EVERYTHING - Serial USB controllers - device configuration-manager and
    UNINSTALL all but the category itself - REBOOT - it refreshes the drive and battery USB

    This KB shows XP how to and the method of Vista is identical
    http://support.Microsoft.com/kb/310575

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

    If necessary try these two:

    Tips for solving problems of USB devices - and a Mr Fixit
    http://windowshelp.Microsoft.com/Windows/en-us/help/c39bd203-f729-47a4-8351-83291e13c8a81033.mspx#EGB

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

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • "Photographs not in the albums (according to my records) at Revel after that access of all media" fact TICK - sorting Adobe!

    Hello

    It's really frustrating after subscribing to download all my photos to revel.

    After access of all catalog media' ticking, I have the following two issues:

    1 images appear individually to Revel and not in their respective albums according to the 'my files' in the Organizer. At least I have create another new folder in mobile albums (another more than 50!) - But why do I get this and create a lot of work?

    2. not all the images are imported, especially the more recent photos have not downloaded.

    I've updated to 12.1 elements - I use Windows 7 PC and Adobe Revel app on Android.

    It's embarrassing it please help Adobe!

    Rich

    Hi Richard,

    Unfortunately Yes.

    As mentioned on my blog, when you synchronize 'all media' to the online account, it only syncs all your media in your destination library without creating a structure similar to records album mobile.

    Please let me know if you have any question.

    ~ Surendra

  • Setup.exe has stopped working; attempt to remove programs interfering with CD/DVD players

    Still trying to get my CD/DVD drive to read my CD and DVD, I'm trying to follow the advice of Support Dell and get rid of other programs like Power DVD, Nero Burning ROM, Roxio, etc. which could block Windows the drive, but when I go into the Control Panel--> programs-->--> Power DVD uninstallers, he won't let me uninstall it not.

    I hit uninstall and it even does not seem as if he had a chance to try before, he was arrested.

    Heeeeeeeellllp. Help help help help, HELP.

    Hello

    Don't PowerDVD come on your computer? If so I leave and try the methods below. If not use
    Revo Uninstaller to remove it.

    Revo Uninstaller - Free Version
    http://www.revouninstaller.com/revo_uninstaller_free_download.html

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

    Hello

    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

    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/

    I hope this helps.

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

  • How can I remove "Open all in tabs" of my favorites?

    How can I remove "Open all in tabs" of my favorites? It is very annoying when you click on it by mistake. I downgraded from 29 to 28 due to the various bookmark questions I had. I never had this problem with the previous version of FF, why did have to mess with stuff that worked.

    I love the new layout. Thank you

    Add code to the file userChrome.css below default @namespace.

    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    
    #placesContext_openContainer\:tabs,
    #placesContext_openSeparator {
     display: none !important;
    }
    

    The file userChrome.css (UI) customization and userContent.css (Web sites) are located in the folder of chrome in the Firefox profile folder.

    You can use this button to go to the Firefox profile folder currently in use:

    • Help > troubleshooting information > profile directory: see file (Linux: open the directory;) Mac: View in the Finder)
  • HP Slimline s3700y how to remove the Pocket Media DriveBay?

    How the guides do not describe how to REMOVE the Pocket Media Drivebay, what I must do to remove the CD/DVD drive.  The drivebay completely blocks access to the screws that must be removed so that the CD/DVD drive to slide.   Thanks in advance for browsing and/or in response.

    Please see this guide HP titled 'hard drive replacement' for instruction on how to remove the Pocket Media Drive. Step 2 in the section "Removing the primary hard drive" show clearly how to remove Media Player.

    Please send Bravo

  • complete removal of all components (remnants) of all versions of IE from PC

    I deleted all versions of IE from my PC, but IE still infringes on my privacy by installing large files, when I use internet. How to remove completely all of the components of Internet Explorer without affecting my favorite browser (installed)?

    BTW is there some subtleties I agreed without knowing who gives Microsoft the right to install any unwanted, privacy, infringing files on my computer without asking my consent?

    -Gunnar

    As well noted Veritas, as long as you use Windows, you use IE (or a version of it) because it is integrated into the system. It is literally impossible to "remove all components of Internet Explorer".

    If you are concerned that on the issues of confidentiality and Microsoft "offences", I suggest you use many varieties of Linux.
  • How can I remove the rest of the damaged files that Windows Resource Protection could not?

    How can I remove the rest of my corrupted files that Windows Resource Protection did not delete?  It offers no suggestions?  If he deleted some, why can't this?    I did the scan twice, but it says this... CBS. Newspaper windir/Logs/CBS/CBS.log for more details... I don't know how to access, also said the damaged drive was C / windows / System 32/config/software/log is corrupted and unreadable.  Hope that there is a way to solve this problem... Thank you

    Hello

    Try the following and see if it helps.

    I suggest you perform a disk check and check if it helps.

    See the following steps:

    a. open the computer by clicking the Start button, click computer.

    b. click the drive you want to check, and then click Properties.

    c. click on the Tools tab and then, under error-checking, click Find now.  If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.

    d. to automatically repair problems with files and folders that the scan detects, select automatically fix file system errors. Otherwise, the disk check will be a problem, but not to fix them.

    e. to carry out a thorough, check select search for and attempt recovery of bad sectors. This analysis tries to find and repair physical errors on the disk itself, and it may take much longer to complete.

    f. to check for errors file and the physical errors, select both automatically fix errors in file system and search for and attempt recovery of bad sectors.

    g. click on start.

    Note: When running chkdsk on the drive hard if bad sectors are found on the disk hard when chkdsk attempts to repair this area if all available on which data can be lost.

    Note: Make sure also that you have disconnected all external devices except the keyboard and mouse.

    Note: If you are always faced with the question then I suggest you to upgrade on the spot and check if it helps.

    How to perform an upgrade in Place on Windows Vista, Windows 7, Windows Server 2008 and Windows Server 2008 R2: http://support.microsoft.com/kb/2255099
    Note: Before you perform the upgrade on the spot, I would recommend you to back your files using windows backup.

  • Whenever I tried to run the Windows Media Center it says that it has stopped working and he's looking for solutions.

    Hello

    I installed Windows 7 this weekend with the offer of the student. Whenever I tried to run the Windows Media Center it says that it has stopped working and he's looking for solutions. Is it possible that I can download a fix or download the WMC for Windows 7?

    My computer (laptop) is a gateway T-6836 64-bit.

    original title: WIndows 7 media center has stopped working

    I upgraded to Win7 upgrade thestudent and my WMC keeps stopping whenever I try to open it. Is there a way to fix this or if I do a clean install of the operating system?

    This is the error I get:

    Description
    Stopped working
    Path of the Application of vulnerabilities: C:\Windows\ehome\ehshell.exe

    Signature of the problem
    Problem event name: CLR20r3
    Signature of the problem 01: ehshell.exe
    Signature of the problem 02: 6.1.7600.16385
    Signature of the problem 03: 4a5bd053
    Signature of the problem 04: mcstore
    Signature of the problem 05: 6.1.0.0
    Signature of the 06 problem: 4a5bda1e
    Signature problem 07: 1 a 1
    Signature of the 08:146 problem
    Signature of the problem 09: System.InvalidOperationException
    OS version: 6.1.7600.2.0.0.768.3
    Locale ID: 1033

    Additional information about the problem
    Bucket ID: 655435415

    When you see failing requests like this, even if you get it to work, you never know what's going to arise later.  I suggest to use the feature of easy to backup transfer all your data and do a clean install.

  • Silverlight has been installed on my dell with media player and after that the tuner has stoped running silverlight would have something to do with it? I get a low rate and no signal tuner.

    Silverlight has been installed on my dell with media player and after that the tuner has stoped running silverlight would have something to do with it? I get a low rate and no signal tuner.

    Hello

    Thanks for the quick response.

    What web browser do you use to access the links in my previous post?

    If you use Internet Explorer, I suggest to optimize Internet Explorer settings and check if it works.

     

     

     

    How to optimize Internet Explorer

    http://support.Microsoft.com/kb/936213/ro

     

    Warning: Please note that the reset Internet Explorer (IE) resets all of the settings defined by the user, including those established by the installed extensions, toolbars and other add-ons for IE by default. This includes all the security, privacy and settings area. Also this will erase browsing history, delete all temporary Internet, cookies, form data files and especially all the passwords.

     

    If the problem persists, you can reinstall the drivers for the Tuner card and check with the question.

    It will be useful. For any other corresponding Windows help, do not hesitate to contact us and we will be happy to help you.

Maybe you are looking for

  • Continue to be "online survey" when I try to log

    Surveys online & pop-up advertising reappear when I connect to my email or visit different sites, that began last week, is at - it a virus on my computer to dictate this and how then I block it. I tried to block browsing history already.

  • Die Power Mac or an anomaly in the system serious?

    Power Mac G5 (June 2004 version) OS X Version 10.5.8 I have a 700 GB drive, which has an operating system partition and a single data where I save the work and other files. A couple of weeks, I used SilverKeeper to the ice to back up my apps folder a

  • Configuration and closing the new disk for Portege R100

    I just set up a new 40 GB HDD in my Portege r100. I think I need to format the disk before that it will work. How to do this please? I downloaded and installed the latest version of the bios

  • How to extend the partition C on Satellite L450 - 17K

    Hello I'm working on how I can change the size of the partition on my hard drive my C drive is nearly full, and D is a pain to keep anything on that most of what I have links to my Ipad that does not detect it when its on drive D! Is there anyway to

  • FVS318N connection problem

    I wonder if anyone who met the situation where a FVS318N rejects all connection attempts despite usernames and passwords entered are correct. Whenever I try to connect, I get the following error: Provided username is not part of the Administrator/com