You would need to take away the 'mandatory' part of the parameter definition.
And assign a value inside the script.
The first couple of lines could look like this
param(
# VMs to monitor for OS customization completion
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $vmList = (Get-VM -Name vm1,vm2,vm3),
# timeout in seconds to wait
[int] $timeoutSeconds = 600
)
But to be honest, if you don't want to use parameters when calling the script, you can just as well leave out the complete Param part.
And just do the following at the beginning of the script.
$timeoutSeconds = 600
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In that script the parameter vmList is defined as mandatory.
So you will have to provide that parameter
.\Clone_VM.ps1 -vmList $vms
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I would like to mention the parameters inside the script rather than mentioning outside while running.
Please help in changing that.
You would need to take away the 'mandatory' part of the parameter definition.
And assign a value inside the script.
The first couple of lines could look like this
param(
# VMs to monitor for OS customization completion
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]] $vmList = (Get-VM -Name vm1,vm2,vm3),
# timeout in seconds to wait
[int] $timeoutSeconds = 600
)
But to be honest, if you don't want to use parameters when calling the script, you can just as well leave out the complete Param part.
And just do the following at the beginning of the script.
$timeoutSeconds = 600
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much LucD.
That worked perfect