<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ESXI PoweCLI Creating new NTFS partition with newly created VM in VMware vCenter Converter SDK Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-vCenter-Converter-SDK/ESXI-PoweCLI-Creating-new-NTFS-partition-with-newly-created-VM/m-p/2889507#M717</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Im looking for someone who can help me with my problem.&lt;/P&gt;&lt;P&gt;I am using ESXI and PowerCLI to automate a Windows 10 creation and installation.&lt;/P&gt;&lt;P&gt;I made a unatended ISO so that all the setup questions are ingored. But my ISO wants to look for a NTFS hard disk to install on.&lt;/P&gt;&lt;P&gt;So now in my script im trying to setup a new partition before it loads the ISO into the new VM. But I cant seem to get it right. It says: Error: A positional parameter cannot be found that accepts argument 'New-Partition'.&lt;/P&gt;&lt;P&gt;Im doing this for a school project and i have little experience with Powershell but so far it has been very interesting.&lt;/P&gt;&lt;P&gt;My code: (ive used the main part that was created by David Rodrigeuz and added the commands i needed to it)&lt;/P&gt;&lt;P&gt;&amp;lt;#&lt;BR /&gt;===========================================================================&lt;BR /&gt;Script Created by: David Rodriguez&lt;BR /&gt;Blog: &lt;A href="http://www.sysadmintutorials.com" target="_blank"&gt;www.sysadmintutorials.com&lt;/A&gt;&lt;BR /&gt;Twitter: @systutorials&lt;BR /&gt;Youtube: &lt;A href="https://www.youtube.com/user/sysadmintutorials" target="_blank"&gt;https://www.youtube.com/user/sysadmintutorials&lt;/A&gt;&lt;BR /&gt;===========================================================================&lt;BR /&gt;.DESCRIPTION&lt;BR /&gt;This script will automate the creation of virtual machine within ESXi&lt;BR /&gt;#&amp;gt;&lt;/P&gt;&lt;P&gt;$vmhostipaddress = Read-Host "Enter the IP of your VMware ESXi Host"&lt;BR /&gt;$vmhostcreds = Get-Credential -Message "Please enter the root username and password"&lt;/P&gt;&lt;P&gt;Write-Host -ForegroundColor Yellow "`n---- Connecting to VMware ESXi Host ----"&lt;BR /&gt;try{&lt;BR /&gt;Connect-VIServer $vmhostipaddress -User "$($vmhostcreds.UserName)" -Password ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($vmhostcreds.Password))) -ErrorAction Stop | Out-Null&lt;BR /&gt;Write-Host -ForegroundColor Green "Successfully connected to VMware ESXi Host"&lt;BR /&gt;}&lt;BR /&gt;catch&lt;BR /&gt;{&lt;BR /&gt;Write-Warning -Message $("Something went wrong connecting to the ESXi host. Please read the error message and re-run the script. Error: "+ $_.Exception.Message)&lt;BR /&gt;Break;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Operating system options" -ForegroundColor Yellow&lt;BR /&gt;Write-Host "1. Windows10"&lt;BR /&gt;Write-Host "2. Linux"&lt;/P&gt;&lt;P&gt;$operatingsystem = Read-Host "Select the Operating System you wish to install by typing in either 1 or 2?"&lt;/P&gt;&lt;P&gt;IF ($operatingsystem -eq 1)&lt;BR /&gt;{&lt;BR /&gt;$guestid = "windows9_64Guest"&lt;BR /&gt;}&lt;BR /&gt;IF ($operatingsystem -eq 2)&lt;BR /&gt;{&lt;BR /&gt;$guestid = "ubuntu64Guest"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;$vmname = Read-Host "Please enter the name of the virtual machine?"&lt;BR /&gt;$cpuamount = Read-Host "How many CPU's would you like to provision?"&lt;BR /&gt;$ramamount = Read-Host "How much RAM do you wish to provision in GB's?"&lt;BR /&gt;$hddamount = Read-Host "How much Disk storage do you wish to provision in GB's?"&lt;/P&gt;&lt;P&gt;try&lt;BR /&gt;{&lt;BR /&gt;New-VM -Name $vmname -Datastore datastore1 -NumCpu $cpuamount -MemoryGB $ramamount -DiskGB $hddamount -DiskStorageFormat Thin -NetworkName "VM Network" -CD -GuestId $guestid -ErrorAction Stop | Out-Null&lt;BR /&gt;Get-VM $vmname New-Partition -DiskNumber 0 -size $hddamount&lt;BR /&gt;Get-VM $vmname | Get-NetworkAdapter | Set-NetworkAdapter -Type VMXNet3 -Confirm:$False -ErrorAction Stop | Out-Null&lt;BR /&gt;Start-VM $vmname -confirm&lt;BR /&gt;get-vm -name $vmname | get-cddrive| Set-CDDrive -Connected $true -IsoPath '[datastore1] ISO2\en_windows_10_multiple_editions_x64_dvd_6846432.iso' -startconnected $true&lt;BR /&gt;Write-Host "Successfully created $($vmname)" -ForegroundColor Green&lt;BR /&gt;}&lt;BR /&gt;catch&lt;BR /&gt;{&lt;BR /&gt;Write-Warning -Message $("Something went wrong in creating the virtual machine: $($vmname). Please read the error message and re-run the script. Error: "+ $_.Exception.Message)&lt;BR /&gt;Break;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jan 2022 14:14:17 GMT</pubDate>
    <dc:creator>Footyfoot</dc:creator>
    <dc:date>2022-01-21T14:14:17Z</dc:date>
    <item>
      <title>ESXI PoweCLI Creating new NTFS partition with newly created VM</title>
      <link>https://communities.vmware.com/t5/VMware-vCenter-Converter-SDK/ESXI-PoweCLI-Creating-new-NTFS-partition-with-newly-created-VM/m-p/2889507#M717</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Im looking for someone who can help me with my problem.&lt;/P&gt;&lt;P&gt;I am using ESXI and PowerCLI to automate a Windows 10 creation and installation.&lt;/P&gt;&lt;P&gt;I made a unatended ISO so that all the setup questions are ingored. But my ISO wants to look for a NTFS hard disk to install on.&lt;/P&gt;&lt;P&gt;So now in my script im trying to setup a new partition before it loads the ISO into the new VM. But I cant seem to get it right. It says: Error: A positional parameter cannot be found that accepts argument 'New-Partition'.&lt;/P&gt;&lt;P&gt;Im doing this for a school project and i have little experience with Powershell but so far it has been very interesting.&lt;/P&gt;&lt;P&gt;My code: (ive used the main part that was created by David Rodrigeuz and added the commands i needed to it)&lt;/P&gt;&lt;P&gt;&amp;lt;#&lt;BR /&gt;===========================================================================&lt;BR /&gt;Script Created by: David Rodriguez&lt;BR /&gt;Blog: &lt;A href="http://www.sysadmintutorials.com" target="_blank"&gt;www.sysadmintutorials.com&lt;/A&gt;&lt;BR /&gt;Twitter: @systutorials&lt;BR /&gt;Youtube: &lt;A href="https://www.youtube.com/user/sysadmintutorials" target="_blank"&gt;https://www.youtube.com/user/sysadmintutorials&lt;/A&gt;&lt;BR /&gt;===========================================================================&lt;BR /&gt;.DESCRIPTION&lt;BR /&gt;This script will automate the creation of virtual machine within ESXi&lt;BR /&gt;#&amp;gt;&lt;/P&gt;&lt;P&gt;$vmhostipaddress = Read-Host "Enter the IP of your VMware ESXi Host"&lt;BR /&gt;$vmhostcreds = Get-Credential -Message "Please enter the root username and password"&lt;/P&gt;&lt;P&gt;Write-Host -ForegroundColor Yellow "`n---- Connecting to VMware ESXi Host ----"&lt;BR /&gt;try{&lt;BR /&gt;Connect-VIServer $vmhostipaddress -User "$($vmhostcreds.UserName)" -Password ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($vmhostcreds.Password))) -ErrorAction Stop | Out-Null&lt;BR /&gt;Write-Host -ForegroundColor Green "Successfully connected to VMware ESXi Host"&lt;BR /&gt;}&lt;BR /&gt;catch&lt;BR /&gt;{&lt;BR /&gt;Write-Warning -Message $("Something went wrong connecting to the ESXi host. Please read the error message and re-run the script. Error: "+ $_.Exception.Message)&lt;BR /&gt;Break;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Operating system options" -ForegroundColor Yellow&lt;BR /&gt;Write-Host "1. Windows10"&lt;BR /&gt;Write-Host "2. Linux"&lt;/P&gt;&lt;P&gt;$operatingsystem = Read-Host "Select the Operating System you wish to install by typing in either 1 or 2?"&lt;/P&gt;&lt;P&gt;IF ($operatingsystem -eq 1)&lt;BR /&gt;{&lt;BR /&gt;$guestid = "windows9_64Guest"&lt;BR /&gt;}&lt;BR /&gt;IF ($operatingsystem -eq 2)&lt;BR /&gt;{&lt;BR /&gt;$guestid = "ubuntu64Guest"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;$vmname = Read-Host "Please enter the name of the virtual machine?"&lt;BR /&gt;$cpuamount = Read-Host "How many CPU's would you like to provision?"&lt;BR /&gt;$ramamount = Read-Host "How much RAM do you wish to provision in GB's?"&lt;BR /&gt;$hddamount = Read-Host "How much Disk storage do you wish to provision in GB's?"&lt;/P&gt;&lt;P&gt;try&lt;BR /&gt;{&lt;BR /&gt;New-VM -Name $vmname -Datastore datastore1 -NumCpu $cpuamount -MemoryGB $ramamount -DiskGB $hddamount -DiskStorageFormat Thin -NetworkName "VM Network" -CD -GuestId $guestid -ErrorAction Stop | Out-Null&lt;BR /&gt;Get-VM $vmname New-Partition -DiskNumber 0 -size $hddamount&lt;BR /&gt;Get-VM $vmname | Get-NetworkAdapter | Set-NetworkAdapter -Type VMXNet3 -Confirm:$False -ErrorAction Stop | Out-Null&lt;BR /&gt;Start-VM $vmname -confirm&lt;BR /&gt;get-vm -name $vmname | get-cddrive| Set-CDDrive -Connected $true -IsoPath '[datastore1] ISO2\en_windows_10_multiple_editions_x64_dvd_6846432.iso' -startconnected $true&lt;BR /&gt;Write-Host "Successfully created $($vmname)" -ForegroundColor Green&lt;BR /&gt;}&lt;BR /&gt;catch&lt;BR /&gt;{&lt;BR /&gt;Write-Warning -Message $("Something went wrong in creating the virtual machine: $($vmname). Please read the error message and re-run the script. Error: "+ $_.Exception.Message)&lt;BR /&gt;Break;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 14:14:17 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-vCenter-Converter-SDK/ESXI-PoweCLI-Creating-new-NTFS-partition-with-newly-created-VM/m-p/2889507#M717</guid>
      <dc:creator>Footyfoot</dc:creator>
      <dc:date>2022-01-21T14:14:17Z</dc:date>
    </item>
  </channel>
</rss>

