Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 244951

Re: When creating a linked cloned, prompt for which cluster and cluster datastore

$
0
0

You can also make the Cluster, DatastoreClusterName, VM and Server mandatory parameters for your script. Then you can run your script with parameters. If you don't specify the parameters when running the script, the script will ask for the parameter values. Insert the following piece of code at the beginning of your script.

 

Param ([Parameter(Mandatory=$true)][String]$Cluster,       [Parameter(Mandatory=$true)][String]$DatastoreClusterName,       [Parameter(Mandatory=$true)][String]$VM,       [Parameter(Mandatory=$true)][String]$Server="vcenter.domain")

 

In the above parameters definition the script will not prompt for the Server variable value because there is already a default value given.

 

You can now run your script with:

 

.\New-LinkedClone.ps1 -Cluster cluster-3 -DatastoreClusterName cluster-3-bronze -VM test*

If you run your script with just:

 

.\New-LinkedClone.ps1

 

then it will prompt for the Cluster, DatastoreClusterName and VM.


Viewing all articles
Browse latest Browse all 244951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>