About
Welcome to thelowercasew.com – a site dedicated to virtualization and VMware!
What does the name “Lowercase w” mean? Over the years I’ve seen every possible misspelling of VMware known to man. Everything from VMWare to Vm Ware to VmWare to…you get the idea. I’ve seen VMware employees do it.. heck even I used to do it myself!
ABOUT ME
I’m currently a Consulting Systems Engineer working for HBR Consulting. I’ve been working with VMware products for over 15 years now. In my current role working for an MSP, I support and maintain vSphere environments of multiple customers, around the globe.
Over the years, I’ve been working to automate more and more of my daily tasks. Whenever I have to do something more than once, I look to script it so I can do it again, faster, with repeatable results.
I was named VMware vExpert each year since 2015, as well as a VMware Tanzu Vanguard for 2023! I’m also a Devolutions Expert. You can learn more about the Devolutions products at www.devolutions.net.
I am also a Leader of the New Jersey VMUG (VMware User Group). NJ VMUG Meets quarterly in New Brunswick, NJ. You can find us by clicking the link HERE or you can find us on Twitter, Facebook, and LinkedIn. We also have a YouTube channel.
I hold multiple VMware Certified Professional Certifications. VCP4-DCV, VCP5-DCV, VCP6-DCV, and most recently, VCP-DCV 2019! I’m currently working on renewing my VCP certification.
You can find Ben on LinkedIn below:
2 thoughts on “About”
Comments are closed.
Hello Ben,
I came across your interesting deploying-vms-via-powercli-csv-file blog post.
I am a novice when it comes to creating scripts and rely on using scripts provided by experts like yourself and at the moment I am trying to automate my Citrix Lab environment builds. I know how to do it using MDT but this requires a server VM but I was looking at the powerful Invoke-Script PowerCLI command.
Using your script I am having an issue with discovering my single datastore. I get the following output and errors because it is not able to find the datastore and subseqently the vlan label from the CSV file because I have a standard switch configuration. I have a single ESXi 6.7 host cluster configured with a vCenter server and using a Standard Switch.
I have posted the output below of the error messages. Will be very grateful if you could please help me out with how to modify the script to query the datastore
Thanks,
Mayur
PS C:\Scripts> C:\Scripts\AutoDeploy.ps1
Select which vCenter to connect to:
.
1. vCenter1
2. vCenter2
3. vCenter3
4. vCenter4
Select a vCenter Server. Enter Number.: 1
.
You Picked: vc01.lab.local
.
Name Port User
—- —- —-
vc01.lab.local 443 LAB\VI-Admin
.
Select an OS to deploy:
.
1. Windows Server 2016 Standard
2. Windows Server 2012 R2 Standard
3. Windows Server 2008 R2 Standard
Select Operatingg System. Enter Number.: 1
.
You Picked: Win2016
.
.
Choose a Cluster to deploy VMs into:
(it may take a few seconds to build the list)
.
1: Local
Enter the number for the cluster to deploy to.: 1
.
You have selected Local.
.
.
Choose a Datastore Cluster to deploy to:
.
Enter a number ( 1 – 0 ): 1
Cannot index into a null array.
At C:\Scripts\AutoDeploy.ps1:97 char:5
+ $SDatastore = $Datastores[$DSIndex – 1].Name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
You have selected
Select which folder to store the VM…
1: Datacenters
2: datastore
3: Discovered virtual machine
4: host
5: network
6: vm
Select a Folder. Enter a number ( 1 – 6 ): 3
.
You Picked folder: \ Discovered virtual machine
.
New-VM : Cannot validate argument on parameter ‘Datastore’. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At C:\Scripts\AutoDeploy.ps1:127 char:71
+ … me -VMHost $vmhost -Template $Template -Datastore $SDatastore -DiskSt …
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [New-VM], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Comma
nds.NewVM
New-NetworkAdapter : Cannot validate argument on parameter ‘DistributedSwitch’. The argument is null.
Provide a valid value for the argument, and then try running the command again.
At C:\Scripts\AutoDeploy.ps1:132 char:53
+ New-Networkadapter -vm $Name -DistributedSwitch $vdswitch -Portgr …
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [New-NetworkAdapter], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Comma
nds.VirtualDevice.NewNetworkAdapter
Set-VM : 19/12/2018 14:05:54 Set-VM Could not find VirtualMachine with name ‘DC02’.
At C:\Scripts\AutoDeploy.ps1:140 char:5
+ Set-VM $Name -OSCustomizationSpec $SSpec -Confirm:$False
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (DC02:String) [Set-VM], VimException
+ FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNotFound,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.SetVM
Set-VM : 19/12/2018 14:05:54 Set-VM Value cannot be found for the mandatory parameter VM
At C:\Scripts\AutoDeploy.ps1:140 char:5
+ Set-VM $Name -OSCustomizationSpec $SSpec -Confirm:$False
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-VM], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.
SetVM
I’m not sure why your comment came in under the ABOUT page and not on the post itself, but try using this code for the datastore section instead. It’ll detect the datastores and list them.
# DATASTORE
write-Host “Please select a datastore from the list below.”
write-host “*** Please try to keep approx 10% free after deployment when choosing. ***”
$Datastores = Get-VMHost $SVMHost | Get-Datastore | Select Name,FreeSpaceGB,CapacityGB | Sort-Object CapacityGB
$y = 1
$Datastores | %{Write-Host $y”:” $_.Name”`t`tCapacity (GB):” $_.CapacityGB”`t`tFree Space (GB):” $_.FreeSpaceGB; $y++}
$DSIndex = Read-Host “Enter a number ( 1 -” $Datastores.count “)”
$SDatastore = $Datastores[$DSIndex – 1].Name
Write-Host “You have selected” $SDatastore