AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
New-EC2Instance-ImageId <String>-AssociatePublicIp <Boolean>-UserDataFile <String>-EncodeUserData <SwitchParameter>-AdditionalInfo <String>-Placement_Affinity <String>-IamInstanceProfile_Arn <String>-MaintenanceOptions_AutoRecovery <InstanceAutoRecoveryState>-Placement_AvailabilityZone <String>-BlockDeviceMapping <BlockDeviceMapping[]>-CapacityReservationTarget_CapacityReservationId <String>-CapacityReservationSpecification_CapacityReservationPreference <CapacityReservationPreference>-CapacityReservationTarget_CapacityReservationResourceGroupArn <String>-HibernationOptions_Configured <Boolean>-CreditSpecification_CpuCredit <String>-CpuOption <CpuOptionsRequest>-DisableApiStop <Boolean>-DisableApiTermination <Boolean>-EbsOptimized <Boolean>-ElasticGpuSpecification <ElasticGpuSpecification[]>-ElasticInferenceAccelerator <ElasticInferenceAccelerator[]>-EnclaveOptions_Enabled <Boolean>-EnablePrimaryIpv6 <Boolean>-PrivateDnsNameOptions_EnableResourceNameDnsAAAARecord <Boolean>-PrivateDnsNameOptions_EnableResourceNameDnsARecord <Boolean>-Placement_GroupId <String>-Placement_GroupName <String>-Placement_HostId <String>-PrivateDnsNameOptions_HostnameType <HostnameType>-Placement_HostResourceGroupArn <String>-MetadataOptions_HttpEndpoint <InstanceMetadataEndpointState>-MetadataOptions_HttpProtocolIpv6 <InstanceMetadataProtocolState>-MetadataOptions_HttpPutResponseHopLimit <Int32>-MetadataOptions_HttpToken <HttpTokensState>-InstanceInitiatedShutdownBehavior <ShutdownBehavior>-InstanceMarketOption <InstanceMarketOptionsRequest>-MetadataOptions_InstanceMetadataTag <InstanceMetadataTagsState>-InstanceType <InstanceType>-Ipv6AddressCount <Int32>-Ipv6Address <InstanceIpv6Address[]>-KernelId <String>-KeyName <String>-LaunchTemplate <LaunchTemplateSpecification>-LicenseSpecification <LicenseConfigurationRequest[]>-MaxCount <Int32>-MinCount <Int32>-Monitoring <Boolean>-IamInstanceProfile_Name <String>-NetworkInterface <InstanceNetworkInterfaceSpecification[]>-Placement_PartitionNumber <Int32>-PrivateIpAddress <String>-RamdiskId <String>-SecurityGroupId <String[]>-SecurityGroup <String[]>-Placement_SpreadDomain <String>-SubnetId <String>-TagSpecification <TagSpecification[]>-Placement_Tenancy <Tenancy>-UserData <String>-ClientToken <String>-Select <String>-PassThru <SwitchParameter>-Force <SwitchParameter>-ClientConfig <AmazonEC2Config>
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | BlockDeviceMappings |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | CapacityReservationSpecification_CapacityReservationTarget_CapacityReservationId |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | CapacityReservationSpecification_CapacityReservationTarget_CapacityReservationResourceGroupArn |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | CpuOptions |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | CpuCredit, CreditSpecification_CpuCredits |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | ElasticInferenceAccelerators |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | InstanceProfile_Arn |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | InstanceProfile_Id, InstanceProfile_Name |
Required? | False |
Position? | 1 |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | InstanceMarketOptions |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | Ipv6Addresses |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | LicenseSpecifications |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | MetadataOptions_HttpTokens |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | MetadataOptions_InstanceMetadataTags |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | Monitoring_Enabled |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | NetworkInterfaces, NetworkInterfaceSet |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | Affinity |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AvailabilityZone |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | PlacementGroup |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | HostId, Placement_Host |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | Tenancy |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | SecurityGroups |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | SecurityGroupIds |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | TagSpecifications |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AK |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AWSProfilesLocation, ProfilesLocation |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | StoredCredentials, AWSProfileName |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | RegionToCall |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | SK, SecretAccessKey |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | ST |
New-EC2Instance -ImageId ami-12345678 -MinCount 1 -MaxCount 1 -InstanceType m3.medium -KeyName my-key-pair -SecurityGroup my-security-groupThis example launches a single instance of the specified AMI in EC2-Classic or a default VPC.
New-EC2Instance -ImageId ami-12345678 -MinCount 1 -MaxCount 1 -SubnetId subnet-12345678 -InstanceType t2.micro -KeyName my-key-pair -SecurityGroupId sg-12345678This example launches a single instance of the specified AMI in a VPC.
$bdm = New-Object Amazon.EC2.Model.BlockDeviceMapping
$bdm.VirtualName = "ephemeral0"
$bdm.DeviceName = "/dev/sdf"
New-EC2Instance -ImageId ami-12345678 -BlockDeviceMapping $bdm ...To add an EBS volume or an instance store volume, define a block device mapping and add it to the command. This example adds an instance store volume.
$ami = Get-EC2ImageByName WINDOWS_2016_BASE
New-EC2Instance -ImageId $ami.ImageId ...To specify one of the current Windows AMIs, get its AMI ID using Get-EC2ImageByName. This example launches an instance from the current base AMI for Windows Server 2016.
New-EC2Instance -ImageId ami-1a2b3c4d -InstanceType m4.large -KeyName my-key-pair -SecurityGroupId sg-1a2b3c4d -AvailabilityZone us-west-1a -Tenancy host -HostID h-1a2b3c4d5e6f1a2b3Launches an instance into the specified dedicated host environment.
$tag1 = @{ Key="webserver"; Value="production" }
$tag2 = @{ Key="cost-center"; Value="cc123" }
$tagspec1 = new-object Amazon.EC2.Model.TagSpecification
$tagspec1.ResourceType = "instance"
$tagspec1.Tags.Add($tag1)
$tagspec2 = new-object Amazon.EC2.Model.TagSpecification
$tagspec2.ResourceType = "volume"
$tagspec2.Tags.Add($tag2)
New-EC2Instance -ImageId "ami-1a2b3c4d" -KeyName "my-key-pair" -MaxCount 2 -InstanceType "t2.large" -SubnetId "subnet-1a2b3c4d" -TagSpecification $tagspec1,$tagspec2This request launches two instances and applies a tag with a key of webserver and a value of production to the instances. The request also applies a tag with a key of cost-center and a value of cc123 to the volumes that are created (in this case, the root volume for each instance).
AWS Tools for PowerShell: 2.x.y.z