@Siegfried Heintze Welcome to Microsoft Q&A, thank you for posting your here!!
I have reproduced this issue in my test subscription if your Source Virtual Machine is Gen2 then you have to create the image config with -HyperVGeneration as V2 and was able to create the image successfully.
please try with the below commands
Make sure the VM has been deallocated.
$vmName = "IMAGEGEN2VM" #VMname
$rgName = "Ramya" #Resourcegroup name
$location = "EastUS" #Region where the VM is deployed
$imageName = "myImage" #Image Name
Stop-AzVM -ResourceGroupName $rgName -Name $vmName -Force
OperationId :
Status : Succeeded
StartTime : 1/20/2023 8:15:58 AM
EndTime : 1/20/2023 8:16:11 AM
Error :
Set the status of the virtual machine to Generalized.
Set-AzVm -ResourceGroupName $rgName -Name $vmName -Generalized
OperationId :
Status : Succeeded
StartTime : 1/20/2023 8:16:15 AM
EndTime : 1/20/2023 8:16:16 AM
Error :
Create the image configuration and Create the Image
$vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName
$image = New-AzImageConfig -Location $location -SourceVirtualMachineId $vm.Id -HyperVGeneration "V2"
New-AzImage -Image $image -ImageName $imageName -ResourceGroupName $rgName
ResourceGroupName : Ramya
SourceVirtualMachine : Microsoft.Azure.Management.Compute.Models.SubResource
StorageProfile : Microsoft.Azure.Management.Compute.Models.ImageStorageProfile
ProvisioningState : Succeeded
HyperVGeneration : V2
Id : /subscriptions/SubID/resourceGroups/Ramya/providers/Microsoft.Compute/images/myImage
Name : myImage
Type : Microsoft.Compute/images
Location : eastus
ExtendedLocation :
Tags : {}
Hope this helps!
Kindly let us know if the above helps or you need further assistance on this issue.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.