Set-AzVMSecurityProfile
Anger SecurityType-uppräkningen för Virtual Machines.
Syntax
Default (Standard)
Set-AzVMSecurityProfile
[-VM] <PSVirtualMachine>
[-SecurityType <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
Cmdleten Set-AzVMSecurityProfile anger säkerhetstypen för den virtuella datorn
Exempel
Exempel 1
$VM = Get-AzVM -ResourceGroupName "ResourceGroup11" -VMName "ContosoVM07"
$VM = Set-AzVMSecurityProfile -VM $VM -SecurityType "TrustedLaunch"
Det första kommandot hämtar den virtuella datorn med namnet ContosoVM07 med hjälp av Get-AzVm. Kommandot lagrar det i variabeln $VM. Det andra kommandot anger SecurityType-uppräkningen till "TrustedLaunch". Betrodd start kräver att nya virtuella datorer skapas. Du kan inte aktivera betrodd start på befintliga virtuella datorer som ursprungligen skapades utan den.
Exempel 2: Skapa en virtuell ConfidentialVM-dator och disken krypterad med typen VMGuestStateOnly.
$vmSize = "Standard_DC2as_v5";
$DNSNameLabel = "cvm1" +$ResourceGroupName;
$SubnetAddressPrefix = "10.0.0.0/24";
$VnetAddressPrefix = "10.0.0.0/16";
# Credential setup.
$securePassword = ConvertTo-SecureString -String "****" -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$SecurityType = "ConfidentialVM";
$vmDiskSecurityEncryptionType = "VMGuestStateOnly";
$VirtualMachine = New-AzVMConfig -VMName $VMName -VMSize $VMSize;
# Create the Network resources and VM OS setup.
$SingleSubnet = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix $SubnetAddressPrefix;
$Vnet = New-AzVirtualNetwork -Name $NetworkName -ResourceGroupName $rgname -Location $LocationName -AddressPrefix $VnetAddressPrefix -Subnet $SingleSubnet;
$PIP = New-AzPublicIpAddress -Name $PublicIPAddressName -DomainNameLabel $DNSNameLabel -ResourceGroupName $rgname -Location $LocationName -AllocationMethod Dynamic;
$NIC = New-AzNetworkInterface -Name $NICName -ResourceGroupName $rgname -Location $LocationName -SubnetId $Vnet.Subnets[0].Id -PublicIpAddressId $PIP.Id;
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $Credential -ProvisionVMAgent -EnableAutoUpdate;
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id;
$VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName 'MicrosoftWindowsServer' -Offer 'windowsserver' -Skus '2022-datacenter-smalldisk-g2' -Version 'latest';
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -StorageAccountType "StandardSSD_LRS" -CreateOption "FromImage";
# Set the SecurityType and necessary values on the Uefi settings.
$VirtualMachine = Set-AzVMSecurityProfile -VM $VirtualMachine -SecurityType $SecurityType;
$VirtualMachine = Set-AzVMUefi -VM $VirtualMachine -EnableVtpm $true -EnableSecureBoot $true;
# Set the Disk Encryption Type.
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -StorageAccountType "StandardSSD_LRS" -CreateOption "FromImage" -SecurityEncryptionType $vmDiskSecurityEncryptionType;
$vm = New-AzVM -ResourceGroupName $rgname -Location $LocationName -VM $VirtualMachine;
$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname;
# Verify SecurityType value.
# $vm.SecurityProfile.SecurityType == "ConfidentialVM";
Parametrar
-DefaultProfile
Autentiseringsuppgifter, konto, klientorganisation och prenumeration som används för kommunikation med Azure.
Parameteregenskaper
| Typ: | IAzureContextContainer |
| Standardvärde: | None |
| Stöder jokertecken: | False |
| DontShow: | False |
| Alias: | AzContext, AzureRmContext, AzureCredential |
Parameteruppsättningar
(All)
| Position: | Named |
| Obligatorisk: | False |
| Värde från pipeline: | False |
| Värde från pipeline efter egenskapsnamn: | False |
| Värde från återstående argument: | False |
-SecurityType
Anger SecurityType för den virtuella datorn. Det måste anges till ett angivet värde för att aktivera UefiSettings. Som standard aktiveras inte UefiSettings om inte den här egenskapen har angetts.
Parameteregenskaper
| Typ: | String |
| Standardvärde: | None |
| Stöder jokertecken: | False |
| DontShow: | False |
Parameteruppsättningar
(All)
| Position: | Named |
| Obligatorisk: | False |
| Värde från pipeline: | False |
| Värde från pipeline efter egenskapsnamn: | True |
| Värde från återstående argument: | False |
-VM
Profilen för den virtuella datorn.
Parameteregenskaper
| Typ: | PSVirtualMachine |
| Standardvärde: | None |
| Stöder jokertecken: | False |
| DontShow: | False |
| Alias: | VMProfile |
Parameteruppsättningar
(All)
| Position: | 0 |
| Obligatorisk: | True |
| Värde från pipeline: | True |
| Värde från pipeline efter egenskapsnamn: | True |
| Värde från återstående argument: | False |
CommonParameters
Den här cmdleten stöder vanliga parametrar: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction och -WarningVariable. Mer information finns i about_CommonParameters.