Edit

Share via


Add-AzVMAdditionalUnattendContent

Adds information to the unattended Windows Setup answer file.

Syntax

Default (Default)

Add-AzVMAdditionalUnattendContent
    [-VM] <PSVirtualMachine>
    [[-Content] <String>]
    [[-SettingName] <SettingNames>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The Add-AzVMAdditionalUnattendContent cmdlet adds information to the unattended Windows Setup answer file. Specify additional base 64 encoded .xml formatted information that this cmdlet adds to the unattend.xml file.

Examples

Example 1: Add content to unattend.xml

$AvailabilitySet = Get-AzAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet03"
$VirtualMachine = New-AzVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id
$Credential = Get-Credential
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine  -Windows -ComputerName "Contoso26" -Credential $Credential
$AucContent = "<UserAccounts><AdministratorPassword><Value>" + "Password" + "</Value><PlainText>true</PlainText></AdministratorPassword></UserAccounts>";
$VirtualMachine = Add-AzVMAdditionalUnattendContent -VM $VirtualMachine -Content $AucContent -SettingName "AutoLogon"

The first command gets the availability set named AvailabilitySet03 in the resource group named ResourceGroup11, and then stores that object in the $AvailabilitySet variable. The second 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 third command creates a credential object by using the Get-Credential cmdlet, and then stores the result in the $Credential variable. The command prompts you for a user name and password. For more information, type Get-Help Get-Credential. The fourth command uses the Set-AzVMOperatingSystem cmdlet to configure the virtual machine stored in $VirtualMachine. The fifth command assigns content to the $AucContent variable. The content includes a password. The final command adds the content stored in $AucContent to the unattend.xml file.

Parameters

-Content

Specifies base 64 encoded XML formatted content. This cmdlet adds the content to the unattend.xml file. The XML content must be less than 4 KB and must include the root element for the setting or feature that this cmdlet inserts.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SettingName

Specifies the name of the setting to which the content applies. The acceptable values for this parameter are:

  • FirstLogonCommands
  • AutoLogon

Parameter properties

Type:

Nullable<T>[SettingNames]

Default value:None
Accepted values:AutoLogon, FirstLogonCommands
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:2
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-VM

Specifies the virtual machine object that this cmdlet modifies. To obtain a virtual machine object, use the Get-AzVM cmdlet. Create a virtual machine object by using the New-AzVMConfig cmdlet.

Parameter properties

Type:PSVirtualMachine
Default value:None
Supports wildcards:False
DontShow:False
Aliases:VMProfile

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

PSVirtualMachine

String

Nullable<T>

Outputs

PSVirtualMachine