This script can be referred for configuring bare metal with vMedia policy.
Below are the global parameter which must be set before executing script according your requirement.
# Global Variables
$ImageFileName = 'VMware-ESXi-6.7.0-9484548-Custom-Cisco-6.7.0.2.iso'
$ImagePath = '/'
$RemoteIpAddress = '1.1.2.1'
$UserId = 'root'
$Password = '12345'
$RemotePort = '80'
$DeviceType = 'cdd'
$Protocol = 'http'
$BootPolicyName = 'TestBootPolicy'
$vMediaPolicyName = 'TestvMediaPolicy'
Here it will first check available blade server (similarly you can modify code for rack server) for association. Based on provided service profile template it will create Service profile which will be then associated with blade server. In the service profile template we have associated boot policy and vMedia policy.
Once association done it will power up the server and reset it to boot it in provided boot order. You can proceed with installation.
Example :
.\AutomateUCSTasks_v3.ps1 -Ucs 1.2.2.1 -UcsOrg 'root' -UcsSpTemplate 'Test-SPTemplate' -UcsBladeDn 'sys/chassis-1/blade-5' -Hostname 'Test-SP-Amol1'