What is the best way to declare input variables that we want to use in a script?
As of now I either declare all the needed variables above the script or create a separate VariableDeclaration.ps1
and dot-source it in the main script.
Is there a better way to get this done?
Reason I want to do this is because I want to make it easy for my peers to use the script without having much knowledge of scripting. They can easily edit the variables defined in a separate file (maybe INI or XML) without touching the main script.
Any suggestions?
Variables declaration sample:
#Customer_details
$CustomerID = '100'
$CustomerName = "ABCorp"
$vCenterName = "vCenter.ABCorp.com"
$vCenterUserName = "administrator@vsphere.local"
$vCenterPassword = ConvertTo-SecureString -String "ABCorp123" -AsPlainText -Force;
$CustomerPODLocation = "VW1"
$DatacenterName = "ABCorpDC"
$ClusterName = "ABCorpcluster"
$InfraResourcePoolName = $CustomerID + "-" + $CustomerName + "-" + "Infrastructure"
$FolderName = $CustomerID + "-" + $CustomerName
$ConnectionType = "S2S"
$VLANID = '237'
$PortGroupName = $ConnectionType + "-" + $CustomerID + "-" + $CustomerName + "-" + $VLANID
$NumberofPorts = '1024'