{"id":762,"date":"2020-03-16T09:17:47","date_gmt":"2020-03-16T08:17:47","guid":{"rendered":"https:\/\/blog.mhasin.eu\/?p=762"},"modified":"2020-03-16T09:56:20","modified_gmt":"2020-03-16T08:56:20","slug":"power-shell-create-vm-vmware-vcenter","status":"publish","type":"post","link":"https:\/\/blog.mhasin.eu\/?p=762","title":{"rendered":"Power shell create VM VMWARE vcenter"},"content":{"rendered":"\n<p>Vytvorenie VM pomocou powershell. (Pre spr\u00e1vnu funk\u010dnos\u0165 je potrebne sa pripoji\u0165 na vcenter server. <a href=\"https:\/\/blog.mhasin.eu\/?p=764\">https:\/\/blog.mhasin.eu\/?p=764<\/a>)<\/p>\n\n\n\n<p>Deploy zo \u0161abl\u00f3ny:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Specify vCenter Server datastore\n$ds = \u201cSST3_1\u201c\n#\n# Specify the vSphere Cluster\n$Cluster = \u201cL9\u201c\n#\n# Specify the VM name to the left of the \u2013 sign\n$VM_prefix = \u201cVM-\u201c\n\n$OSSpecs = Get-OSCustomizationSpec -Name 'windows'\n$VMTemplate = Get-Template -Name 'windows'\n#Get Cluster\n$cluster = Get-Cluster -Name $Cluster\n# Get a host within cluster\n\n$VM_name= $VM_prefix \n$ESXi = Get-Cluster $cluster | Get-VMHost | Get-Random\nwrite-host \u201cCreation of VM $VM_name initiated\u201d  -foreground green\n\n\nNew-VM -Name $VM_Name -Template $VMTemplate -OSCustomizationSpec $OSSpec -VMHost $ESXi -Datastore $ds | Start-VM\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>$VMTemplate = Get-Template -Name &#8218;windows&#8216;  &#8211; Defin\u00edcia \u0161ablony vo vcenter<\/li><li>$OSSpecs = Get-OSCustomizationSpec -Name &#8218;windows&#8216; &#8211; Definovanie customization profilu<\/li><li>$ESXi = Get-Cluster $cluster | Get-VMHost | Get-Random &#8211; v\u00fdber n\u00e1hodn\u00e9ho hosta z dan\u00e9ho klastra<\/li><\/ul>\n\n\n\n<p>Zapnutie VM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Start-VM -VM $VM_name -confirm:$false -RunAsync<\/code><\/pre>\n\n\n\n<p><\/p>\n<div class=\"pdf24Plugin-cp\"> \t<form name=\"pdf24Form0\" method=\"post\" action=\"https:\/\/doc2pdf.pdf24.org\/wordpress.php\" target=\"pdf24PopWin\" onsubmit=\"var pdf24Win = window.open('about:blank', 'pdf24PopWin', 'resizable=yes,scrollbars=yes,width=600,height=250,left='+(screen.width\/2-300)+',top='+(screen.height\/3-125)+''); pdf24Win.focus(); if(typeof pdf24OnCreatePDF === 'function'){void(pdf24OnCreatePDF(this,pdf24Win));}\"> \t\t<input type=\"hidden\" name=\"blogCharset\" value=\"Cw1x07UAAA==\" \/><input type=\"hidden\" name=\"blogPosts\" value=\"MwQA\" \/><input type=\"hidden\" name=\"blogUrl\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLQUA\" \/><input type=\"hidden\" name=\"blogName\" value=\"c\/LxdwcA\" \/><input type=\"hidden\" name=\"blogValueEncoding\" value=\"gzdeflate base64\" \/><input type=\"hidden\" name=\"postId_0\" value=\"MzczAgA=\" \/><input type=\"hidden\" name=\"postTitle_0\" value=\"C8gvTy1SKM5IzclRSC5KTSxJVQjzBaJwxyBXhbLk1LyS1CIA\" \/><input type=\"hidden\" name=\"postLink_0\" value=\"yygpKSi20tdPyslP18vNSCzOzNNLLdW3L7A1NzMCAA==\" \/><input type=\"hidden\" name=\"postAuthor_0\" value=\"y00syfcwNAIA\" \/><input type=\"hidden\" name=\"postDateTime_0\" value=\"MzIwMtA1MNY1NFMwsLQyMLYyMQcA\" \/><input type=\"hidden\" name=\"postContent_0\" value=\"nVTBbtNAEL37K0ZJROHgWAVUSpsYoRTRA2lRXUWIS7Wx1\/G2693V7tohVQ\/9AU5c4dADBw6cOHMK\/ZF+CbN2nJS2ggpfvOPdeW\/ezPN6PRWOZraUmgpGYTQEJXMZywLfU6pNRjnvwsO3moJRen5RigLSQpz8+iikufwKxxQPWk3HAg8QUJopecxwQxAoYyos1WCoLqnuQo9Apmnab2XWKrMVBGMuJ908I4aJLi2CF6r\/bONpK\/zrdi8g4aNeoEIPHyx+hyouZ3Aq4fKCjPn8h5htrbax7JgTY\/qtqfIRLz7xY5nQVthzr7ANkaIxS2dQDupao6pWSIglxmJTvE5ioA9X55+j6PDJ0TouvLa3yrMZhTJSGUWmAS8MYnidxaLOe\/P8rhxstCA5BSurkNPUgkyr9dX5JzBsIrzOaHiEClL2oUYaDX0H5XX2Iwfl6npNrb8fDZBO5uyUWCaF2wJ\/z4GvTZlI5NSsOahDmitOLF1kLcObR9u4u5ISL6W4pEZYndPoRGkuB6crjYUpsxkTsEj0KhVOah+u6fE6r6J37Abqkuys+jwa7jq8OjggWF7uTTWz1K94sBUDTSvJrnPY0IYJmGCWobbk6vwLgJ\/iHCdaFiKBiaZUoDP26BTxGx2YVy1WTbnerzsbvJgBNFXWevydxjfgfHMGkSXaKfF6QWU4dKamtTcLfsuanBmL1uQs\/Oe8HrQ3H69vbi+mVkUb21B\/Xt+GHeyymH+PGal\/CynQ4rL5I3sBUlQ093XS3XR\/sMmSuBskvo6A94FMGS9WhP819iVROf85xoNifpHJRMy\/ZbLyHIFT\/GPr+AR7ajWpGYOCN\/fEe6JEYasr7v73QzM+N+aVvfCISJnOtzop4Qbjg0K8NDMR3x6yCiuu3w==\" \/> \t\t<a href=\"https:\/\/www.pdf24.org\" target=\"_blank\" title=\"www.pdf24.org\" rel=\"nofollow\"><img src=\"https:\/\/blog.mhasin.eu\/wp-content\/plugins\/pdf24-post-to-pdf\/img\/pdf_32x32.png\" alt=\"\" border=\"0\" height=\"32\" \/><\/a> \t\t<span class=\"pdf24Plugin-cp-space\">&nbsp;&nbsp;<\/span> \t\t<span class=\"pdf24Plugin-cp-text\">Send article as PDF<\/span> \t\t<span class=\"pdf24Plugin-cp-space\">&nbsp;&nbsp;<\/span> \t\t<input class=\"pdf24Plugin-cp-input\" style=\"margin: 0px;\" type=\"text\" name=\"sendEmailTo\" placeholder=\"Enter email address\" \/> \t\t<input class=\"pdf24Plugin-cp-submit\" style=\"margin: 0px;\" type=\"submit\" value=\"Send\" \/> \t<\/form> <\/div>","protected":false},"excerpt":{"rendered":"Vytvorenie VM pomocou powershell. (Pre spr\u00e1vnu funk\u010dnos\u0165 je potrebne sa pripoji\u0165 na vcenter server. https:\/\/blog.mhasin.eu\/?p=764) Deploy zo \u0161abl\u00f3ny: $VMTemplate = Get-Template -Name &#8218;windows&#8216; &#8211; Defin\u00edcia \u0161ablony vo vcenter $OSSpecs = Get-OSCustomizationSpec -Name &#8218;windows&#8216; &#8211; Definovanie customization profilu $ESXi = Get-Cluster $cluster | Get-VMHost | Get-Random &#8211; v\u00fdber n\u00e1hodn\u00e9ho hosta z dan\u00e9ho klastra Zapnutie VM: &nbsp;&nbsp; Send article as PDF &nbsp;&nbsp;\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"arc_restricted_post":false,"footnotes":""},"categories":[7,2],"tags":[],"class_list":["post-762","post","type-post","status-publish","format-standard","hentry","category-programovanie","category-vmware"],"_links":{"self":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=762"}],"version-history":[{"count":3,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/762\/revisions"}],"predecessor-version":[{"id":788,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=\/wp\/v2\/posts\/762\/revisions\/788"}],"wp:attachment":[{"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mhasin.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}