public VMProperties() { // No VM can live without these, so provision them Networking = new VMNetworkProfile(); OSProfile = new VMOSProfile(); Storage = new VMStorageSettings(); }
/// <summary> /// Create VM operating system profile for Windows OS /// </summary> /// <param name="hostName">Hostname for the VM</param> /// <param name="administratorUserName">Username to use for the Administrator user</param> /// <param name="administratorPasword">Password for the Administrator user</param> /// <param name="timeZoneName">Name of the timezone</param> /// <param name="enableAutomaticUpdates">Enable automatic (Windows) updates</param> /// <param name="provisionVMAgent">Flag to provision the VMAgent service inside the VM</param> /// <returns>The OS profile</returns> public static VMOSProfile CreateProfileForWindows(string hostName, string administratorUserName, string administratorPasword, string timeZoneName, bool enableAutomaticUpdates = true, bool provisionVMAgent = true) { if (!IsValidHostName(hostName)) { throw new ArgumentNullException(nameof(hostName)); } if (string.IsNullOrWhiteSpace(administratorUserName)) { throw new ArgumentNullException(nameof(administratorUserName)); } if (string.IsNullOrWhiteSpace(administratorPasword)) { throw new ArgumentNullException(nameof(administratorPasword)); } if (string.IsNullOrWhiteSpace(timeZoneName)) { throw new ArgumentNullException(nameof(timeZoneName)); } VMOSProfile profile = new VMOSProfile() { Hostname = hostName, AdministratorUserName = administratorUserName, AdministratorPassword = administratorPasword, Windows = new VMSettingsForWindows() { AdditionalCommands = null, EnabledAutomaticUpdates = enableAutomaticUpdates, ShouldProvisionVMAgent = provisionVMAgent, TimeZoneName = timeZoneName, WinRM = new WinRMConfiguration() { Listeners = new List <WinRMListener>() { { new WinRMListener() { CertificateURI = null, Protocol = WinRMProtocolsEnum.https } } } } } }; return(profile); }