Skip to content

Latest commit

 

History

History
522 lines (366 loc) · 13.1 KB

File metadata and controls

522 lines (366 loc) · 13.1 KB

Command line arguments

This page describes the command line arguments supported by the Answer File Generator, which are used to customize the generated answer file. All argument names are case insensitive.

Argument values can be specified as either e.g. -JoinDomain mydomain, -JoinDomain:mydomain or -JoinDomain=mydomain.

Some arguments can be specified multiple times. This can be done by listing several values after the argument:

-LocalAccount "John,Password" "Dave,OtherPassword" -EnableRemoteDesktop

Or, by repeating the argument multiple times, potentially interleaving other arguments:

-LocalAccount "John,Password" -EnableRemoteDesktop -LocalAccount "Dave,OtherPassword"

This syntax makes Answer File Generator compatible with PowerShell hash table splatting, which can be a convenient way to handle invocations with many arguments.

$arguments = @{
    "OutputPath" = "unattend.xml"
    "InstallMethod" = "CleanEfi"
    "Feature" = "Microsoft-Windows-Subsystem-Linux","VirtualMachinePlatform"
    "WindowsVersion" = "10.0.22621.1"
    "EnableRemoteDesktop" = $true
}

./GenerateAnswerFile @arguments

The arguments are split into several categories:

Usage syntax

GenerateAnswerFile
    [-OutputFile] <Path>
    [-AutoLogonCount <Number>]
    [-AutoLogonPassword <String>]
    [-AutoLogonUser <[Domain\]User>]
    [-CmdKeyPassword <String>]
    [-CmdKeyUser <Domain\User>]
    [-ComputerName <String>]
    [-DisableCloud]
    [-DisableDefender]
    [-DisableServerManager]
    [-DisplayResolution <Size>]
    [-DomainAccount <String>...]
    [-EnableRemoteDesktop]
    [-Feature <String>...]
    [-FirstLogonCommand <String>...]
    [-Help]
    [-ImageIndex <Number>]
    [-Install <InstallMethod>]
    [-InstallToDisk <Number>]
    [-InstallToPartition <Number>]
    [-JoinDomain <String>]
    [-JoinDomainPassword <String>]
    [-JoinDomainUser <[Domain\]User>]
    [-Language <String>]
    [-LocalAccount <Name,Password>...]
    [-OnlineHelp]
    [-OUPath <String>]
    [-Partition <Label:Size>...]
    [-ProcessorArchitecture <String>]
    [-ProductKey <String>]
    [-SetupScript <String>...]
    [-TimeZone <String>]
    [-Version]
    [-WindowsVersion <Version>]

General options

-OutputFile

The path and file name to write the answer file to.

Value: <Path>
Aliases: -o
Required: True
Positional: True

-Help

Displays a help message.

Value: [<Boolean>]
Aliases: -?, -h

-OnlineHelp

Shows additional help in your web browser, including example usage.

Value: [<Boolean>]
Aliases: -oh, -??

-Version

Displays version information.

Value: [<Boolean>]

Installation options

-Feature

The name of an optional feature to install. Use the PowerShell Get-WindowsOptionalFeature command to get a list of valid feature names. Can have multiple values.

Must not be blank.

See optional features.

Value: <String> (multiple allowed)
Aliases: -c
Required arguments: -WindowsVersion
Allowed -Install values: ExistingPartition, CleanBios, CleanEfi, Manual

-ImageIndex

The index of the image in the WIM file to install. Use this for Windows editions not installed using a product key, such as those that use volume licensing. Use the PowerShell Get-WindowsImage command to list all images in a .wim or .esd file.

See selecting the edition to install.

Value: <Number>
Aliases: -wim
Allowed -Install values: ExistingPartition, CleanEfi, CleanBios

-Install

The installation method to use.

See installation method.

Value: PreInstalled, ExistingPartition, CleanEfi, CleanBios, Manual
Aliases: -i
Default value: PreInstalled

-InstallToDisk

The zero-based ID of the disk to install to. This disk will be wiped and repartitioned according to -Partition, or using the default layout if -Partition is not specified.

Must be at least 0.

Value: <Number>
Aliases: -disk
Default value: 0
Allowed -Install values: ExistingPartition, CleanEfi, CleanBios

-InstallToPartition

The one-based ID of the partition to install to, on the disk specified by -InstallToDisk. If not specified and -Install is CleanEfi or CleanBios, Windows will be installed on the first regular data partition. If -Install is ExistingPartition, the default value is 3, which is appropriate for UEFI systems with the default partition layout.

Must be at least 1.

Value: <Number>
Aliases: -part
Allowed -Install values: CleanEfi, CleanBios, ExistingPartition

-Partition

A partition to create on the disk specified by -InstallToDisk. Can have multiple values.

Use the format label:size or label:size[fs], where label is the volume label, size is the size of the partition, and fs is an optional file system like FAT32 or NTFS. Sizes can use multiple-byte units such as GB, and will be truncated to whole megabytes. For example System:100MB, Windows:128GB, or Data:16GB[FAT32].

Use * as the size to extend the partition to fill the remainder of the disk (e.g. Windows:*).

Use the following labels to create special partitions: System, MSR, WinRE, and Recovery.

If not specified, the default partition layout for the method specified by -Install is used.

See custom partition layout.

Value: <Label:Size> (multiple allowed)
Aliases: -p
Allowed -Install values: CleanEfi, CleanBios

-ProductKey

The product key used to select what edition to install, and to activate Windows.

Must not be blank.

See selecting the edition to install.

Value: <String>
Aliases: -key

-WindowsVersion

The exact version and build number (e.g. 10.0.22621.1) of the OS being installed. This argument is only used when -Feature is specified.

Value: <Version>
Aliases: -v

User account options

-CmdKeyPassword

The password of the user specified by -CmdKeyUser.

Must not be blank.

Value: <String>
Aliases: -ckp
Required arguments: -CmdKeyUser

-CmdKeyUser

The name of a user used to access all network resources, in domain\user format. If present, the cmdkey.exe application will be used at first logon to save this user's credentials for all network paths

Must not be blank.

Value: <Domain\User>
Aliases: -cku
Required arguments: -CmdKeyPassword

-LocalAccount

A local account to create, using the format name,password. Can have multiple values. If no local accounts are created, the user will be asked to create one during OOBE, making setup not fully unattended.

See creating a user during installation.

Value: <Name,Password> (multiple allowed)
Aliases: -a

Automatic logon options

-AutoLogonCount

The number of times the user specified by -AutoLogonCount will be automatically logged on.

Must be at least 1.

Value: <Number>
Aliases: -alc
Default value: 1
Required arguments: -AutoLogonUser

-AutoLogonPassword

The password of the user specified by -AutoLogonCount.

Must not be blank.

Value: <String>
Aliases: -alp
Required arguments: -AutoLogonUser

-AutoLogonUser

The name of a user to automatically log on, in the format domain\user, or just user for local users. If not specified, automatic logon will not be used.

Must not be blank.

See joining a domain and automatic logon.

Value: <[Domain\]User>
Aliases: -alu
Required arguments: -AutoLogonPassword

Domain options

-DomainAccount

The name of a domain account to add to the local administrators group. Must be in the domain you're joining. Can have multiple values.

Must not be blank.

Value: <String> (multiple allowed)
Aliases: -da
Required arguments: -JoinDomain

-JoinDomain

The name of a domain to join. If not specified, the system will not be joined to a domain.

Must not be blank.

See joining a domain and automatic logon.

Value: <String>
Aliases: -jd
Required arguments: -JoinDomainUser, -JoinDomainPassword

-JoinDomainPassword

The password of the user specified by -JoinDomainUser. Will be stored in plain text.

Must not be blank.

Value: <String>
Aliases: -jdp
Required arguments: -JoinDomain

-JoinDomainUser

The name of a user with permission to join the domain specified by -JoinDomain. Use the format domain\user, or just user if the user is a member of the domain you are joining.

Must not be blank.

Value: <[Domain\]User>
Aliases: -jdu
Required arguments: -JoinDomain

-OUPath

The organizational unit to use when joining the domain specified by -JoinDomain.

Must not be blank.

Value: <String>
Aliases: -ou
Required arguments: -JoinDomain

Other setup options

-ComputerName

The network name for the computer.

Must not be blank.

Value: <String>
Aliases: -n

-DisableCloud

Disable Windows cloud consumer features. This prevents auto-installation of recommended store apps.

Value: [<Boolean>]
Aliases: -dc

-DisableDefender

Disable Windows Defender virus and threat protection.

Value: [<Boolean>]
Aliases: -d

-DisableServerManager

Do not automatically start Server Manager when logging on (Windows Server only).

Value: [<Boolean>]
Aliases: -dsm

-DisplayResolution

The display resolution, in the format width,height. For example, 1920,1080. If not specified, the default resolution is determined by Windows.

Value: <Size>
Aliases: -res

-EnableRemoteDesktop

Turn on remote desktop, and create a Windows Defender Firewall rule to allow incoming connections.

Value: [<Boolean>]
Aliases: -rdp

-FirstLogonCommand

A command to run during first logon. Can have multiple values. Commands are executed before the scripts specified by -SetupScript.

Must not be blank.

See first log-on commands and scripts.

Value: <String> (multiple allowed)
Aliases: -cmd

-Language

The language used for the UI language, and the input, system and user locales.

Must not be blank.

Value: <String>
Aliases: -lang
Default value: en-US

-ProcessorArchitecture

The processor architecture of the Windows edition you're installing. Use amd64 for 64 bit Intel and AMD processors, x86 for 32 bit, and arm64 for ARM-based devices.

Must not be blank.

See installing a 32 bit OS.

Value: <String>
Aliases: -arch
Default value: amd64

-SetupScript

The full path of a Windows PowerShell script to run during first logon. Can have multiple values. Scripts are executed after the commands specified by -FirstLogonCommand.

Must not be blank.

See first log-on commands and scripts.

Value: <String> (multiple allowed)
Aliases: -s

-TimeZone

The time zone that Windows will use. Run tzutil /l for a list of valid values.

Must not be blank.

Value: <String>
Default value: Pacific Standard Time