create a VM

I want to create virtual machines using PowerCLi (New - VM cmdlet). On VMFS data warehouses, virtual machines must be thick and NFS data warehouses, they should be thin.

I don't know the type of data store, or if it's a store Cluster data or just a single data store.

I thought about setting a variable in my script type datastore as such databases:

If the data store is VMFS, set $DSType = 'thick '.

If the data store is NFS, set $DSType = 'end '.

and then create the virtual machine using

New-VM-name $VMName - DiskStorageFormat $DSType - $Datastore Datastore

I come with a logic (just for debugging) and it works if I use one of the two:

1 $DatastoreName = get-DatastoreCluster-name 'Datastore_Cluster_Name ' | Get-Datastore. Select-Object - 1 first

or

2 - $DatastoreName = get-Datastore-name "Datastore_Name"

the IF works or of which the above:

If ($DatastoreName.type - eq "VMFS")

{

$DSType = 'thick '.

echo $DSType

}

If ($DatastoreName.type - eq "NFS")

{

$DSType = 'thin '.

echo $DSType

}

Get-DatastoreCluster works ONLY for cluster of data store, while Get-data store works ONLY for the data store.

I need a function/cmdlet that can work with a name (which may be the data store or cluster) and does not return them an error.

You can use a Try-Catch, something like this construction

$name = "datastorecluster_or_datastorename".

Try {}

$ds = get - DatastoreCluster - name $name - ErrorAction Stop | Get-Datastore. Select - 1 first

}

Catch {}

$ds = get-Datastore-name $name

}

$ds

Tags: VMware

Similar Questions

  • Failed to create photo memories

    I use the mac on the Sierra photos app, update that became my mac perfect condition a paralyzed slug.

    According to the help of photos I can create a memory of an album as follows:

    1. Click on an album under Albums in the sidebar.
    2. Click Show as memory.
    3. Scroll down and click on add to memories

    My problem is that I do not see 'display in memory '.

    This means that I have no way to create a slideshow. No idea why I don't see "display memory"?

    Concerning

    My problem is that I do not see 'display in memory '.

    When you select an album in the sidebar, 'Show as memory' is under the search field in the toolbar.

    It is only available for standard albums, not for the smart albums.

  • Node of automation is much more difficult to 'uncheck' than to 'create '.

    I use logical X about 5 months now, and I felt a fairly frustrating relationship with interaction of automation.  When I load automation, 'creation' of a knot of automation is simple... 1. click anywhere along the yellow line creates a node that is precisely where I clicked.  However, "popping/unclicking/destroy" this same node takes anywhere from 3 to 6 clicks to work.  I would love to be able to uncheck these nodes with the same exact ease with which I am able to create.  No relief in this case would be great!  Thank you

    Double click on the node to remove it... as simple as when it was created...   Click to create, double-click Delete.

  • WHAT YEAR MODEL MODEL MC976LL/A WAS CREATED

    WHAT YEAR MODEL MODEL MC976LL/A WAS CREATED

    2012.

    http://www.EveryMac.com/systems/Apple/Macbook_pro/specs/MacBook-Pro-core-I7-2.6-15-mid-2012-retina-display-specs.html

  • Can I create a recovery bootable USB through disk utility?

    My HARD drive is dying, I can't access my Macintosh HD partition anymore and I can't reinstall OS because I SMART errors. Before the format and reinstall the attempt to load slow my computer, random errors, etc. So I definitely think that the HARD drive is near death. My plan is to replace my HDD for a Virgin SSD, I perform this task several times on computers of the victory but for MAC, I wonder how I will load the new OS. Can I make a bootable USB with the recovery partition, but on a USB key tools? Unofrtunately I have more available Mac to create the USB bootable through itunes.

    My computer is the MacBook Pro (13-inch mid 2010), I have also all original packaging somewhere, if there is a CD that I can use, I certainly can get too.

    Any advice?

    Thank you!

    Apple have this to do a USB installation...

    Create an installer for OS X - Apple support bootable

    Another option is to use the diskmakerx.com application

    You must have the OS installer downloaded to make these methods of work is probably not practice on your failed drive.

    Both of these options are to run a 'normal' operating system too. The recovery partition is not 'normal '.

    Another option is to use the Internet recovery mode if your Mac supports...

    Computers that can be upgraded to use OS X Internet Recovery - Apple Support

    On macOS recovery - Apple Support

    Use wired ethernet for best results, since it will download a bootable OS & then download the installer of the OS also.

    I suspect you have the update of the firmware installed to add this feature if it has been updated over the last 3 years

    You may be able to generate a score of alternative recovery to another disk (such as a USB key) If you want to just "compensation of base OS.

    OS X: on Recovery Disk Wizard - Apple Support

    A last solution would be to clone your drive failing on an external drive (or use the new SSD in a proper case). That can be done in the modes of recovery via disk utility. Basically, you use a feature to "restore" to clone one volume to another. (I don't see clear instructions for the moment so ask if you want to pursue this option).

  • create Apple ID

    Hi, I have an unknown error, when I create Apple ID.  I am fill all forms of registration of new Apple ID, but in the end, it gives me an error like this: "for assistance to connect this support."

    Click here and ask for help from the staff of the iTunes Store.

    (145024)

  • ITunes can add images to mp3 created from vinyl record?

    I created on a 1000 mp3 files (320 bps, 441hz) of the vinyl record.  Obviously, I can manually create images of these files individually but will take a while, so I was wondering if iTunes can automatically create.  I tried to select all the images in the library by getting album artwork, but it tells me the following statement just ' get album artwork requires you to connect to the iTunes Store using an identifier to Apple. " Please go to the iTunes Store and log in or create a new Apple ID. "I connected to itunes and he always tells me the same thing. Could someone point me in the right direction?  My files are saved on my mac.  Thank you very much

    Yes, you can manually add a picture as the cover to any MP3 song in your iTunes library.  Source of origin has no importance.

    The other issue is separate.  In current iTunes, go to the iTunes menu bar, and then click accounts.  The menu drops down.  At the top of the menu, if you are connected currently, your name and your Apple ID are displayed.  Do you see that?

    If you are connected (and you see your name and your Apple ID), the menu bar

    File-> library-> Get Album Artwork

    You don't need to have whatever it is selected in your library.  iTunes tries to get lack of the album artwork for songs in your library.  iTunes only 'creates' images.  iTunes album art search resource online, based on data from song and download all that is available and adds songs album art.  One (or more) songs will not match available album art.

  • How can I create a group through Outlook without the application Outlook email?

    How can I create a group by using Outlook without an application Outlook email?

    Sigmalambda wrote:

    How can I create a group by using Outlook without an application Outlook email?

    It is difficult to understand what you're trying to do. You can create a group and send an email to the group in any mail client. The recipients can use any e-mail provider or an e-mail client to receive e-mail. Please explain in more detail what you are trying to accomplish.

  • The station to create function has been deleted recently? I can't create more songs on my phone stations.

    When you select the «...» ' to add songs to playlists etc. The option create a station is no longer available.  This feature has been removed?

    I have not used this feature before, but I see a command Station to start in the triple-dot for a song menu.  Is it the same or similar?

  • IMac, how to stop the white icon files when creating new folders?

    Whenever I create a new folder, the folder contains these white icon files that end up getting deleted. Is there a way to prevent this?

    Thank you

    If you create a new folder with the Finder, there is no hierarchy, you get a single empty, empty folder icon, if you create a new folder in the Terminal with the following syntax blue, there is hierarchy.

    # Do the new folder has with B folder it contains. And C in B and D in C files.

    $ mkdir Pei A, B, C, D

    # Just make folder a.

    $ mkdir A

    Are you using a utility Finder replacement, or creating folders from an application or a script?

  • How to create a PDF/X1a on a Mac? (with or without iWork)

    Hi all
    I don't have an idea what is a "PDF/X1a.
    I know how to create or convert PDF files on a mac, with the Preview app and the iWork.

    But a "PDF/X1a? What is c?

    Anyone know how to create or convert a "PDFX/X1a?

    Thanks to you all.

    Here is an explanation:

    https://www.prepressure.com/PDF/basics/PDFX-1A

    Frankly, I didn't know there are different "flavors". I create .pdf for years without knowing or worry about this. I just use an excerpt:

    Or, if you are in a document Pages (iWork as long that is not really exist anymore - there are separate applications: Pages, Numbers, Keynote), use the export as PDF option.

    Have never heard of someone that they were not able to read the PDF, I sent as an attachment.

  • Compressor can create subtitles

    Or compressor can create coded subtitles do I need a separate program for this?

    Yes it can.  Everything is in the user manual.

    http://help.Apple.com/compressor/Mac/4.2/#/cpsr9a2e9329

  • How to create the Sierra startup disk?

    Hello world

    I downloaded Sierra on the App Store.

    Can I create a bootable USB Sierra drive?

    I want to install a new copy of Sierra, not upgrade.

    Thank you

    Abdelaal

    Hello

    The download size is about 4.8 gig and want 8 GB on a USB key or similar.

    I used the command line, but there are other ways.

    http://osxdaily.com/2016/06/15/make-MacOS-Sierra-beta-USB-boot-drive/

    and it may be better (which I used)...

    http://www.Macworld.com/article/3092900/Macs/how-to-create-a-bootable-MacOS-sier ra-Installer - drive.html

  • Bootcamp does not start after you have created the new partition

    Hi, I accidentally created a new partition on my mac OSX 10.11 and then discovered that my bootcamp would not start. After that, I deleted the partition but the disk for the BOOTCAMP partition identifier was disk0s5 instead of disk0s4. is anyway to fix this?

    Thanks in advance.

    The disc is now disk0s4, but when I try to boot in bootcamp, it says no bootable disc detected

  • have forgotten the administrative password and the need to create a new

    have forgotten the administrative password and the need to create a new, but without knowing an old failed to create a new

    your options are explained here

    Change or reset the password of a user account from OS X - Apple support

  • Add a vpn connection in ios 10, method chosen in IKEv2, but I don't have the remote ID. My VPN is created in Sonicwall

    Add a vpn connection in ios 10, method chosen in IKEv2, but I don't have the remote ID. My VPN is created in Sonicwall, waiting for quick reply

    Hi cmscan,

    Thank you for using communities of Apple Support.

    I see that you add a VPN connection using IKEv2, but you do not have the remote ID. I know it's important to be able to set up a virtual private network, you can connect using your iPhone. I'm happy to help you with this.

    You must contact your system administrator to ensure that the settings that you must configure the VPN connection. Please see the iPhone user Guide for more information.

    Have a great day!

Maybe you are looking for

  • FF crashes at startup in all modes

    BP-1c6cfc3d-6ada-479c-a3dd-4fc3f2150323

  • a handle to the system leak

    The number of handles of process (ntkrnlpa.exe) WinXP system increases until the system becomes unstable. I noticed this after having used the process explore (PE) and noticed the system process had tens of thousands of handles open (once I even got

  • my USB not conectec driver doesn't instal no eror show usb device not shown usb me

    My usb device does not show eror conectected lock me eror see the

  • Lost domain user profile

    Hello! Here, in our society it happened that some domain users have lost there profiles. What happened after being inactive (they had holidays from 10 to 30 days, and they were not active in the corporate network). What's really happeningWhen a user

  • HP dv6 Notebook PC ENVY: fingerprint reader

    Product number: E3Z70EA #ABV I did a complete reinstall of Windows 10 and all drivers are installed. I find the biometric Driver for Validity Sensor in the driver manager. Please note that this is a clean installation and not an upgrade. Whenever I t