Set-AzureVMOperatingSystem
Set-AzureVMOperatingSystem
Sets operating system properties for a virtual machine.
Syntax
Parameter Set: Linux
Set-AzureVMOperatingSystem [-VM] <PSVirtualMachine> [-Linux] [-ComputerName] <String> [-Credential] <PSCredential> [[-CustomData] <System.String> ] [[-DisablePasswordAuthentication]] [-Profile <AzureProfile> ] [ <CommonParameters>]
Parameter Set: Windows
Set-AzureVMOperatingSystem [-VM] <PSVirtualMachine> [-Windows] [-ComputerName] <String> [-Credential] <PSCredential> [[-CustomData] <System.String> ] [[-ProvisionVMAgent]] [[-EnableAutoUpdate]] [[-TimeZone] <System.String> ] [[-WinRMHttp]] [[-WinRMHttps]] [[-WinRMCertificateUrl] <System.Uri> ] [-Profile <AzureProfile> ] [ <CommonParameters>]
Detailed Description
The Set-AzureVMOperatingSystem cmdlet sets operating system properties for a virtual machine. You can specify logon credentials computer name, and operating system type.
Parameters
-ComputerName<String>
Specifies the name of the computer.
Aliases |
none |
Required? |
true |
Position? |
3 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Credential<PSCredential>
Specifies the user name and password for the virtual machine as a PSCredential object. To obtain a credential, use the Get-Credential cmdlet. For more information, type Get-Help Get-Credential
.
Aliases |
none |
Required? |
true |
Position? |
4 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
-CustomData<System.String>
Specifies a base-64 encoded string of custom data. This is decoded to a binary array that is saved as a file on the virtual machine. The maximum length of the binary array is 65535 bytes.
Aliases |
none |
Required? |
false |
Position? |
5 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-DisablePasswordAuthentication
Indicates that this cmdlet disables password authentication.
Aliases |
none |
Required? |
false |
Position? |
6 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-EnableAutoUpdate
Indicates that this cmdlet enables auto update.
Aliases |
none |
Required? |
false |
Position? |
7 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-Linux
Indicates that the type of operating system is Linux.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-Profile<AzureProfile>
Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-ProvisionVMAgent
Indicates that the settings require that the virtual machine agent be installed on the virtual machine.
Aliases |
none |
Required? |
false |
Position? |
6 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-TimeZone<System.String>
Specifies the time zone for the virtual machine.
Aliases |
none |
Required? |
false |
Position? |
8 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-VM<PSVirtualMachine>
Specifies the local virtual machine object on which to set operating system properties. To obtain a virtual machine object, use the Get-AzureVM cmdlet. Create a virtual machine object by using the New-AzureVMConfig cmdlet.
Aliases |
VMProfile |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue, ByPropertyName) |
Accept Wildcard Characters? |
false |
-Windows
Indicates that the type of operating system is Windows.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-WinRMCertificateUrl<System.Uri>
Specifies the URI of a WinRM certificate. This needs to be stored in a Key Vault.
Aliases |
none |
Required? |
false |
Position? |
11 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-WinRMHttp
Indicates that this operating system uses HTTP WinRM.
Aliases |
none |
Required? |
false |
Position? |
9 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
-WinRMHttps
Indicates that this operating system uses HTTPS WinRM.
Aliases |
none |
Required? |
false |
Position? |
10 |
Default Value |
none |
Accept Pipeline Input? |
true(ByPropertyName) |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
Examples
Example 1: Set operating system properties for a new virtual machines
The first command converts a password to a secure string, and then stores it in the $SecurePassword variable. For more information, type Get-Help ConvertTo-SecureString
.
The second command creates a credential for the user FullerP and the password stored in $SecurePassword, and then stores the credential in the $Credential variable. For more information, type Get-Help New-Object
.
The third command gets the availability set named AvailablitySet03 in the resource group named ResourceGroup11, and then stores that object in the $AvailabilitySet variable.
The fourth command creates a virtual machine object, and then stores it in the $VirtualMachine variable. The command assigns a name and size to the virtual machine. The virtual machine belongs to the availability set stored in $AvailabilitySet.
The next four commands assign values to variables to use in the following command. Because you could specify these strings directly in the Set-AzureVMOperatingSystem command, this approach is used only for readability. However, you might use an approach such as this in scripts.
The final command sets operating system properties for the virtual machine stored in $VirtualMachine. The command uses the credentials stored in $Credential. The command uses variables assigned in previous commands for some parameters.
$SecurePassword = ConvertTo-SecureString "password" -AsPlainText -Force
PS C:\> $Credential = New-Object System.Management.Automation.PSCredential ("FullerP", $SecurePassword);
PS C:\> $AvailabilitySet = Get-AzureAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet03"
PS C:\> $VirtualMachine = New-AzureVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id
PS C:\> $ComputerName = "ContosoVM122"
PS C:\> $WinRMCertUrl = "https://keyVaultName.vault.azure.net/secrets/secretName/secretVersion"
PS C:\> $TimeZone = "Pacific Standard Time"
PS C:\> $CustomData = "echo 'Hello World'"
PS C:\> $VirtualMachine = Set-AzureVMOperatingSystem -VM $$VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -CustomData $CustomData -WinRMHttp -WinRMHttps -WinRMCertificateUrl $WinRMCertUrl -ProvisionVMAgent -EnableAutoUpdate -TimeZone $TimeZone