< Back

Set-AzureRmVMOperatingSystem

Tue Jan 29, 2019 9:40 pm

NAME Set-AzureRmVMOperatingSystem



SYNOPSIS

Sets operating system properties for a virtual machine.





SYNTAX

Set-AzureRmVMOperatingSystem [-VM] <PSVirtualMachine> [-Linux] [-ComputerName] <String> [-Credential] <PSCredential> [[-CustomData] <String>]

[[-DisablePasswordAuthentication]] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]



Set-AzureRmVMOperatingSystem [-VM] <PSVirtualMachine> [-Windows] [-ComputerName] <String> [-Credential] <PSCredential> [[-CustomData] <String>]

[[-ProvisionVMAgent]] [[-EnableAutoUpdate]] [[-TimeZone] <String>] [[-WinRMHttp]] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]



Set-AzureRmVMOperatingSystem [-VM] <PSVirtualMachine> [-Windows] [-WinRMCertificateUrl] <Uri> [-ComputerName] <String> [-Credential]

<PSCredential> [[-CustomData] <String>] [[-ProvisionVMAgent]] [[-EnableAutoUpdate]] [[-TimeZone] <String>] [[-WinRMHttp]] [-WinRMHttps]

[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]





DESCRIPTION

The Set-AzureRmVMOperatingSystem 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.



Required? true

Position? 2

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`.



Required? true

Position? 3

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-CustomData <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.



Required? false

Position? 4

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-DefaultProfile <IAzureContextContainer>

The credentials, account, tenant, and subscription used for communication with azure.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-DisablePasswordAuthentication [<SwitchParameter>]

Indicates that this cmdlet disables password authentication.



Required? false

Position? 5

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-EnableAutoUpdate [<SwitchParameter>]

Indicates that this cmdlet enables auto update.



Required? false

Position? 6

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Linux [<SwitchParameter>]

Indicates that the type of operating system is Linux.



Required? true

Position? 1

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-ProvisionVMAgent [<SwitchParameter>]

Indicates that the settings require that the virtual machine agent be installed on the virtual machine.



Required? false

Position? 5

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-TimeZone <String>

Specifies the time zone for the virtual machine.



Required? false

Position? 7

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-AzureRmVM cmdlet. Create a virtual machine object by using the New-AzureRmVMConfig cmdlet.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-Windows [<SwitchParameter>]

Indicates that the type of operating system is Windows.



Required? true

Position? 1

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-WinRMCertificateUrl <Uri>

Specifies the URI of a WinRM certificate. This needs to be stored in a Key Vault.



Required? true

Position? 10

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-WinRMHttp [<SwitchParameter>]

Indicates that this operating system uses HTTP WinRM.



Required? false

Position? 8

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-WinRMHttps [<SwitchParameter>]

Indicates that this operating system uses HTTPS WinRM.



Required? true

Position? 9

Default value False

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

PSVirtualMachine

Parameter 'VM' accepts value of type 'PSVirtualMachine' from the pipeline





OUTPUTS

Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine







NOTES









Example 1: Set operating system properties for a new virtual machines



PS C:\\> $SecurePassword = ConvertTo-SecureString "Password" -AsPlainText -Force

PS C:\\> $Credential = New-Object System.Management.Automation.PSCredential ("FullerP", $SecurePassword);

PS C:\\> $AvailabilitySet = Get-AzureRmAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet03"

PS C:\\> $VirtualMachine = New-AzureRmVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id

PS C:\\> $ComputerName = "ContosoVM122"

PS C:\\> $WinRMCertUrl = "http://keyVaultName.vault.azure.net/sec ... retVersion"

PS C:\\> $TimeZone = "Pacific Standard Time"

PS C:\\> $CustomData = "echo 'Hello World'"

PS C:\\> $VirtualMachine = Set-AzureRmVMOperatingSystem -VM $$VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential

-CustomData $CustomData -WinRMHttp -WinRMHttps -WinRMCertificateUrl $WinRMCertUrl -ProvisionVMAgent -EnableAutoUpdate -TimeZone $TimeZone



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-AzureRmVMOperatingSystem 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.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... tingsystem

Get-AzureRmVmssDiskEncryption

New-AzureRmVMConfig