VM Created from Image with Azure Powershell does not set ComputerName












0















I have an Azure Image, which when I use Azure Powershell to create a VM from, despite me setting the ComputerName in the script, the VM is created without setting the ComputerName to the provided value.



Script:



$ImageName = 'MyImage'
$RsgName = 'MyRsg'
$VmName = 'MyNewVM'
$DiagnosticStorageName = 'diagnosticsstore5048'

$cred = Get-Credential -Credential 'TheAdmin'

$Image = Get-AzureRmImage -ImageName $ImageName -ResourceGroupName $RsgName

# Get NIC
$nic = Get-AzureRmNetworkInterface -ResourceGroupName $RsgName

# Configure the new VM
$Vm = New-AzureRmVMConfig -VMName $VmName -VMSize 'Standard_A2_v2'
$Vm = Set-AzureRmVMSourceImage -VM $Vm -Id $Image.Id
$Vm = Set-AzureRmVMOSDisk -VM $Vm -Name $VmName'-disk' -StorageAccountType 'StandardLRS' -DiskSizeInGB '128' -CreateOption FromImage -Caching ReadWrite
$Vm = Add-AzureRmVMNetworkInterface -VM $Vm -Id $nic.Id
$Vm = Set-AzureRmVMBootDiagnostics -VM $Vm -Enable -ResourceGroupName $RsgName -StorageAccountName $DiagnosticStorageName
$Vm = Set-AzureRmVMOperatingSystem -VM $Vm -Windows -ComputerName 'dor' -Credential $Cred -ProvisionVMAgent

New-AzureRmVM -VM $Vm -ResourceGroupName $RsgName -Location 'West Europe' -DisableBginfoExtension


Last time I run the script to create the VM, it left the new VM with a computer name of 'WIN-I80O6J22ENS'
The Image was created as per the process here: https://docs.microsoft.com/en-gb/azure/virtual-machines/windows/capture-image-resource?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Fclassic%2Ftoc.json



UPDATE
Alot of people think that I am not Generalizing the image correctly, so I wanted to add here how I am doing it.
Inside the VM I run:



Start-Process -FilePath $env:windirSystem32SysprepSysprep.exe -ArgumentList "/generalize /oobe /shutdown /unattend:$env:windirSystem32Sysprepunattend.xml"


Unattend.xml only has one setting in it which is to step the TimeZone.



Once this is completed and the VM OS has shut down, I run the following to get the VM, stop it, and set it to Generalized:



# Shutdown Source VM & Generalize
$SourceVM = Get-AzureRmVM -ResourceGroupName $SourceRsg -Name $SourceVMName
$Null = Stop-AzureRMVM -ResourceGroupName $SourceRsg -Name $SourceVMName -Force
Write-Host 'Stopped Source VM'

Set-AzureRmVm -ResourceGroupName $SourceRsg -Name $SourceVMName -Generalized
Write-Host 'Set Source VM to Generalized'


I have noticed that when the last command is ran, the output is:




OperationId :

Status :

StartTime :

EndTime :

Error :




It doesn't actually say if it was successful or not?



After this I create the Image from the VM disk.










share|improve this question





























    0















    I have an Azure Image, which when I use Azure Powershell to create a VM from, despite me setting the ComputerName in the script, the VM is created without setting the ComputerName to the provided value.



    Script:



    $ImageName = 'MyImage'
    $RsgName = 'MyRsg'
    $VmName = 'MyNewVM'
    $DiagnosticStorageName = 'diagnosticsstore5048'

    $cred = Get-Credential -Credential 'TheAdmin'

    $Image = Get-AzureRmImage -ImageName $ImageName -ResourceGroupName $RsgName

    # Get NIC
    $nic = Get-AzureRmNetworkInterface -ResourceGroupName $RsgName

    # Configure the new VM
    $Vm = New-AzureRmVMConfig -VMName $VmName -VMSize 'Standard_A2_v2'
    $Vm = Set-AzureRmVMSourceImage -VM $Vm -Id $Image.Id
    $Vm = Set-AzureRmVMOSDisk -VM $Vm -Name $VmName'-disk' -StorageAccountType 'StandardLRS' -DiskSizeInGB '128' -CreateOption FromImage -Caching ReadWrite
    $Vm = Add-AzureRmVMNetworkInterface -VM $Vm -Id $nic.Id
    $Vm = Set-AzureRmVMBootDiagnostics -VM $Vm -Enable -ResourceGroupName $RsgName -StorageAccountName $DiagnosticStorageName
    $Vm = Set-AzureRmVMOperatingSystem -VM $Vm -Windows -ComputerName 'dor' -Credential $Cred -ProvisionVMAgent

    New-AzureRmVM -VM $Vm -ResourceGroupName $RsgName -Location 'West Europe' -DisableBginfoExtension


    Last time I run the script to create the VM, it left the new VM with a computer name of 'WIN-I80O6J22ENS'
    The Image was created as per the process here: https://docs.microsoft.com/en-gb/azure/virtual-machines/windows/capture-image-resource?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Fclassic%2Ftoc.json



    UPDATE
    Alot of people think that I am not Generalizing the image correctly, so I wanted to add here how I am doing it.
    Inside the VM I run:



    Start-Process -FilePath $env:windirSystem32SysprepSysprep.exe -ArgumentList "/generalize /oobe /shutdown /unattend:$env:windirSystem32Sysprepunattend.xml"


    Unattend.xml only has one setting in it which is to step the TimeZone.



    Once this is completed and the VM OS has shut down, I run the following to get the VM, stop it, and set it to Generalized:



    # Shutdown Source VM & Generalize
    $SourceVM = Get-AzureRmVM -ResourceGroupName $SourceRsg -Name $SourceVMName
    $Null = Stop-AzureRMVM -ResourceGroupName $SourceRsg -Name $SourceVMName -Force
    Write-Host 'Stopped Source VM'

    Set-AzureRmVm -ResourceGroupName $SourceRsg -Name $SourceVMName -Generalized
    Write-Host 'Set Source VM to Generalized'


    I have noticed that when the last command is ran, the output is:




    OperationId :

    Status :

    StartTime :

    EndTime :

    Error :




    It doesn't actually say if it was successful or not?



    After this I create the Image from the VM disk.










    share|improve this question



























      0












      0








      0








      I have an Azure Image, which when I use Azure Powershell to create a VM from, despite me setting the ComputerName in the script, the VM is created without setting the ComputerName to the provided value.



      Script:



      $ImageName = 'MyImage'
      $RsgName = 'MyRsg'
      $VmName = 'MyNewVM'
      $DiagnosticStorageName = 'diagnosticsstore5048'

      $cred = Get-Credential -Credential 'TheAdmin'

      $Image = Get-AzureRmImage -ImageName $ImageName -ResourceGroupName $RsgName

      # Get NIC
      $nic = Get-AzureRmNetworkInterface -ResourceGroupName $RsgName

      # Configure the new VM
      $Vm = New-AzureRmVMConfig -VMName $VmName -VMSize 'Standard_A2_v2'
      $Vm = Set-AzureRmVMSourceImage -VM $Vm -Id $Image.Id
      $Vm = Set-AzureRmVMOSDisk -VM $Vm -Name $VmName'-disk' -StorageAccountType 'StandardLRS' -DiskSizeInGB '128' -CreateOption FromImage -Caching ReadWrite
      $Vm = Add-AzureRmVMNetworkInterface -VM $Vm -Id $nic.Id
      $Vm = Set-AzureRmVMBootDiagnostics -VM $Vm -Enable -ResourceGroupName $RsgName -StorageAccountName $DiagnosticStorageName
      $Vm = Set-AzureRmVMOperatingSystem -VM $Vm -Windows -ComputerName 'dor' -Credential $Cred -ProvisionVMAgent

      New-AzureRmVM -VM $Vm -ResourceGroupName $RsgName -Location 'West Europe' -DisableBginfoExtension


      Last time I run the script to create the VM, it left the new VM with a computer name of 'WIN-I80O6J22ENS'
      The Image was created as per the process here: https://docs.microsoft.com/en-gb/azure/virtual-machines/windows/capture-image-resource?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Fclassic%2Ftoc.json



      UPDATE
      Alot of people think that I am not Generalizing the image correctly, so I wanted to add here how I am doing it.
      Inside the VM I run:



      Start-Process -FilePath $env:windirSystem32SysprepSysprep.exe -ArgumentList "/generalize /oobe /shutdown /unattend:$env:windirSystem32Sysprepunattend.xml"


      Unattend.xml only has one setting in it which is to step the TimeZone.



      Once this is completed and the VM OS has shut down, I run the following to get the VM, stop it, and set it to Generalized:



      # Shutdown Source VM & Generalize
      $SourceVM = Get-AzureRmVM -ResourceGroupName $SourceRsg -Name $SourceVMName
      $Null = Stop-AzureRMVM -ResourceGroupName $SourceRsg -Name $SourceVMName -Force
      Write-Host 'Stopped Source VM'

      Set-AzureRmVm -ResourceGroupName $SourceRsg -Name $SourceVMName -Generalized
      Write-Host 'Set Source VM to Generalized'


      I have noticed that when the last command is ran, the output is:




      OperationId :

      Status :

      StartTime :

      EndTime :

      Error :




      It doesn't actually say if it was successful or not?



      After this I create the Image from the VM disk.










      share|improve this question
















      I have an Azure Image, which when I use Azure Powershell to create a VM from, despite me setting the ComputerName in the script, the VM is created without setting the ComputerName to the provided value.



      Script:



      $ImageName = 'MyImage'
      $RsgName = 'MyRsg'
      $VmName = 'MyNewVM'
      $DiagnosticStorageName = 'diagnosticsstore5048'

      $cred = Get-Credential -Credential 'TheAdmin'

      $Image = Get-AzureRmImage -ImageName $ImageName -ResourceGroupName $RsgName

      # Get NIC
      $nic = Get-AzureRmNetworkInterface -ResourceGroupName $RsgName

      # Configure the new VM
      $Vm = New-AzureRmVMConfig -VMName $VmName -VMSize 'Standard_A2_v2'
      $Vm = Set-AzureRmVMSourceImage -VM $Vm -Id $Image.Id
      $Vm = Set-AzureRmVMOSDisk -VM $Vm -Name $VmName'-disk' -StorageAccountType 'StandardLRS' -DiskSizeInGB '128' -CreateOption FromImage -Caching ReadWrite
      $Vm = Add-AzureRmVMNetworkInterface -VM $Vm -Id $nic.Id
      $Vm = Set-AzureRmVMBootDiagnostics -VM $Vm -Enable -ResourceGroupName $RsgName -StorageAccountName $DiagnosticStorageName
      $Vm = Set-AzureRmVMOperatingSystem -VM $Vm -Windows -ComputerName 'dor' -Credential $Cred -ProvisionVMAgent

      New-AzureRmVM -VM $Vm -ResourceGroupName $RsgName -Location 'West Europe' -DisableBginfoExtension


      Last time I run the script to create the VM, it left the new VM with a computer name of 'WIN-I80O6J22ENS'
      The Image was created as per the process here: https://docs.microsoft.com/en-gb/azure/virtual-machines/windows/capture-image-resource?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Fclassic%2Ftoc.json



      UPDATE
      Alot of people think that I am not Generalizing the image correctly, so I wanted to add here how I am doing it.
      Inside the VM I run:



      Start-Process -FilePath $env:windirSystem32SysprepSysprep.exe -ArgumentList "/generalize /oobe /shutdown /unattend:$env:windirSystem32Sysprepunattend.xml"


      Unattend.xml only has one setting in it which is to step the TimeZone.



      Once this is completed and the VM OS has shut down, I run the following to get the VM, stop it, and set it to Generalized:



      # Shutdown Source VM & Generalize
      $SourceVM = Get-AzureRmVM -ResourceGroupName $SourceRsg -Name $SourceVMName
      $Null = Stop-AzureRMVM -ResourceGroupName $SourceRsg -Name $SourceVMName -Force
      Write-Host 'Stopped Source VM'

      Set-AzureRmVm -ResourceGroupName $SourceRsg -Name $SourceVMName -Generalized
      Write-Host 'Set Source VM to Generalized'


      I have noticed that when the last command is ran, the output is:




      OperationId :

      Status :

      StartTime :

      EndTime :

      Error :




      It doesn't actually say if it was successful or not?



      After this I create the Image from the VM disk.







      azure powershell azure-powershell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 10:03







      Jeffrey

















      asked Nov 13 '18 at 10:48









      JeffreyJeffrey

      8532915




      8532915
























          3 Answers
          3






          active

          oldest

          votes


















          0














          It might be caused by the image not being "Generalized".



          Take a look at the Create a managed image of a generalized VM in Azure guide.



          Hope it helps!






          share|improve this answer
























          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36



















          0














          If you have a specialized image, the Computer name will be missing because the old computer name and the new computer name share the same RID and SID number and on a ideal situation each virtual machine deployment has different RID and SID number. The Computer name can be displayed if the image is a generalized.



          Check this article for more information:



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-specialized



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource






          share|improve this answer
























          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36











          • Use this code to check if the image is truly generalized or specialized (Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk If the CreateOption: FromImage ; the image is properly generalized but if the CreateOption: Attach ; the image is not correctly generalized. If the the CreateOption: FromImage, you could try to redeploy the virtual machine. Hope this helps

            – Paul Oyemakinwa
            Nov 13 '18 at 17:28











          • So I created a VM from my image, and once the VM was created and before doing anything else, I ran '(Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk', which told me 'CreateOption : FromImage', but the computer name was not set to 'dor'

            – Jeffrey
            Nov 15 '18 at 9:42











          • During the image creation, Is the Osstate specified as Generalized, Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows -ManagedDiskId $diskID to check if the image you used in creating the disk is Generalized; use: (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk Check the staus of the OSStae if its truly generalized.. You can always set a new computer name in as much the image used is generalized.

            – Paul Oyemakinwa
            Nov 15 '18 at 11:18











          • Running (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk against my image tells me: OsState : Generalized

            – Jeffrey
            Nov 16 '18 at 10:24



















          0














          The point everyone is trying to make, from your description of the issue, it seems the Image was not generalized correctly or aspect of the generalization failed.



          The script work fine on my end, so the only issue is with the image. Screenshot



          Try another deployment from that image an see is you get the same computer name (WIN-I80O6J22ENS).



          If you get the same name that is a sure confirmation of issue with generalization.



          If the name changes it might mean that the machine you imaged has a policy that is not accepting the name 'dor' so the system is generating default name.



          Either way issue is not with the Powershell or Azure. Hope this helps.






          share|improve this answer
























          • I have tried another deployement from the Image, this time I got a computer name of 'WIN-5LTGQBDHG29'

            – Jeffrey
            Nov 15 '18 at 9:43











          • I have updated the main post with how the Image is being done, this used to work fine and my process hasn't changed, I think I read somewhere the other week that if you use an image to create a VM, then generalize and create and image from that, and keep doing that over and over, eventually it stops setting the computer name

            – Jeffrey
            Nov 15 '18 at 9:54











          • You should not specify an '/unattend' switch, i believe that is whats causing the issue. sysprep without that switch an you should be fine.

            – Hannel
            Nov 15 '18 at 15:36











          • But /unattend is needed to pass in the unattend.xml location? And I need this file to tell it what to set the TimeZone to.

            – Jeffrey
            Nov 16 '18 at 9:53











          • The file means that all OS configuration including Computername is going to be taken from that file. When it doesn't file computername in file, it just generates a default one.

            – Hannel
            Nov 16 '18 at 15:40











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279329%2fvm-created-from-image-with-azure-powershell-does-not-set-computername%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          It might be caused by the image not being "Generalized".



          Take a look at the Create a managed image of a generalized VM in Azure guide.



          Hope it helps!






          share|improve this answer
























          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36
















          0














          It might be caused by the image not being "Generalized".



          Take a look at the Create a managed image of a generalized VM in Azure guide.



          Hope it helps!






          share|improve this answer
























          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36














          0












          0








          0







          It might be caused by the image not being "Generalized".



          Take a look at the Create a managed image of a generalized VM in Azure guide.



          Hope it helps!






          share|improve this answer













          It might be caused by the image not being "Generalized".



          Take a look at the Create a managed image of a generalized VM in Azure guide.



          Hope it helps!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 12:07









          Itay PodhajcerItay Podhajcer

          1,9491412




          1,9491412













          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36



















          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36

















          The image was Generalized, but thanks for the suggestion.

          – Jeffrey
          Nov 13 '18 at 13:36





          The image was Generalized, but thanks for the suggestion.

          – Jeffrey
          Nov 13 '18 at 13:36













          0














          If you have a specialized image, the Computer name will be missing because the old computer name and the new computer name share the same RID and SID number and on a ideal situation each virtual machine deployment has different RID and SID number. The Computer name can be displayed if the image is a generalized.



          Check this article for more information:



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-specialized



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource






          share|improve this answer
























          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36











          • Use this code to check if the image is truly generalized or specialized (Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk If the CreateOption: FromImage ; the image is properly generalized but if the CreateOption: Attach ; the image is not correctly generalized. If the the CreateOption: FromImage, you could try to redeploy the virtual machine. Hope this helps

            – Paul Oyemakinwa
            Nov 13 '18 at 17:28











          • So I created a VM from my image, and once the VM was created and before doing anything else, I ran '(Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk', which told me 'CreateOption : FromImage', but the computer name was not set to 'dor'

            – Jeffrey
            Nov 15 '18 at 9:42











          • During the image creation, Is the Osstate specified as Generalized, Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows -ManagedDiskId $diskID to check if the image you used in creating the disk is Generalized; use: (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk Check the staus of the OSStae if its truly generalized.. You can always set a new computer name in as much the image used is generalized.

            – Paul Oyemakinwa
            Nov 15 '18 at 11:18











          • Running (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk against my image tells me: OsState : Generalized

            – Jeffrey
            Nov 16 '18 at 10:24
















          0














          If you have a specialized image, the Computer name will be missing because the old computer name and the new computer name share the same RID and SID number and on a ideal situation each virtual machine deployment has different RID and SID number. The Computer name can be displayed if the image is a generalized.



          Check this article for more information:



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-specialized



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource






          share|improve this answer
























          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36











          • Use this code to check if the image is truly generalized or specialized (Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk If the CreateOption: FromImage ; the image is properly generalized but if the CreateOption: Attach ; the image is not correctly generalized. If the the CreateOption: FromImage, you could try to redeploy the virtual machine. Hope this helps

            – Paul Oyemakinwa
            Nov 13 '18 at 17:28











          • So I created a VM from my image, and once the VM was created and before doing anything else, I ran '(Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk', which told me 'CreateOption : FromImage', but the computer name was not set to 'dor'

            – Jeffrey
            Nov 15 '18 at 9:42











          • During the image creation, Is the Osstate specified as Generalized, Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows -ManagedDiskId $diskID to check if the image you used in creating the disk is Generalized; use: (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk Check the staus of the OSStae if its truly generalized.. You can always set a new computer name in as much the image used is generalized.

            – Paul Oyemakinwa
            Nov 15 '18 at 11:18











          • Running (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk against my image tells me: OsState : Generalized

            – Jeffrey
            Nov 16 '18 at 10:24














          0












          0








          0







          If you have a specialized image, the Computer name will be missing because the old computer name and the new computer name share the same RID and SID number and on a ideal situation each virtual machine deployment has different RID and SID number. The Computer name can be displayed if the image is a generalized.



          Check this article for more information:



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-specialized



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource






          share|improve this answer













          If you have a specialized image, the Computer name will be missing because the old computer name and the new computer name share the same RID and SID number and on a ideal situation each virtual machine deployment has different RID and SID number. The Computer name can be displayed if the image is a generalized.



          Check this article for more information:



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-specialized



          https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 12:20









          Paul OyemakinwaPaul Oyemakinwa

          11




          11













          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36











          • Use this code to check if the image is truly generalized or specialized (Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk If the CreateOption: FromImage ; the image is properly generalized but if the CreateOption: Attach ; the image is not correctly generalized. If the the CreateOption: FromImage, you could try to redeploy the virtual machine. Hope this helps

            – Paul Oyemakinwa
            Nov 13 '18 at 17:28











          • So I created a VM from my image, and once the VM was created and before doing anything else, I ran '(Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk', which told me 'CreateOption : FromImage', but the computer name was not set to 'dor'

            – Jeffrey
            Nov 15 '18 at 9:42











          • During the image creation, Is the Osstate specified as Generalized, Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows -ManagedDiskId $diskID to check if the image you used in creating the disk is Generalized; use: (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk Check the staus of the OSStae if its truly generalized.. You can always set a new computer name in as much the image used is generalized.

            – Paul Oyemakinwa
            Nov 15 '18 at 11:18











          • Running (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk against my image tells me: OsState : Generalized

            – Jeffrey
            Nov 16 '18 at 10:24



















          • The image was Generalized, but thanks for the suggestion.

            – Jeffrey
            Nov 13 '18 at 13:36











          • Use this code to check if the image is truly generalized or specialized (Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk If the CreateOption: FromImage ; the image is properly generalized but if the CreateOption: Attach ; the image is not correctly generalized. If the the CreateOption: FromImage, you could try to redeploy the virtual machine. Hope this helps

            – Paul Oyemakinwa
            Nov 13 '18 at 17:28











          • So I created a VM from my image, and once the VM was created and before doing anything else, I ran '(Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk', which told me 'CreateOption : FromImage', but the computer name was not set to 'dor'

            – Jeffrey
            Nov 15 '18 at 9:42











          • During the image creation, Is the Osstate specified as Generalized, Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows -ManagedDiskId $diskID to check if the image you used in creating the disk is Generalized; use: (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk Check the staus of the OSStae if its truly generalized.. You can always set a new computer name in as much the image used is generalized.

            – Paul Oyemakinwa
            Nov 15 '18 at 11:18











          • Running (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk against my image tells me: OsState : Generalized

            – Jeffrey
            Nov 16 '18 at 10:24

















          The image was Generalized, but thanks for the suggestion.

          – Jeffrey
          Nov 13 '18 at 13:36





          The image was Generalized, but thanks for the suggestion.

          – Jeffrey
          Nov 13 '18 at 13:36













          Use this code to check if the image is truly generalized or specialized (Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk If the CreateOption: FromImage ; the image is properly generalized but if the CreateOption: Attach ; the image is not correctly generalized. If the the CreateOption: FromImage, you could try to redeploy the virtual machine. Hope this helps

          – Paul Oyemakinwa
          Nov 13 '18 at 17:28





          Use this code to check if the image is truly generalized or specialized (Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk If the CreateOption: FromImage ; the image is properly generalized but if the CreateOption: Attach ; the image is not correctly generalized. If the the CreateOption: FromImage, you could try to redeploy the virtual machine. Hope this helps

          – Paul Oyemakinwa
          Nov 13 '18 at 17:28













          So I created a VM from my image, and once the VM was created and before doing anything else, I ran '(Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk', which told me 'CreateOption : FromImage', but the computer name was not set to 'dor'

          – Jeffrey
          Nov 15 '18 at 9:42





          So I created a VM from my image, and once the VM was created and before doing anything else, I ran '(Get-AzureRmVm -ResourceGroupName <resource-group> -Name <vm-name>).StorageProfile.OsDisk', which told me 'CreateOption : FromImage', but the computer name was not set to 'dor'

          – Jeffrey
          Nov 15 '18 at 9:42













          During the image creation, Is the Osstate specified as Generalized, Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows -ManagedDiskId $diskID to check if the image you used in creating the disk is Generalized; use: (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk Check the staus of the OSStae if its truly generalized.. You can always set a new computer name in as much the image used is generalized.

          – Paul Oyemakinwa
          Nov 15 '18 at 11:18





          During the image creation, Is the Osstate specified as Generalized, Set-AzureRmImageOsDisk -Image $imageConfig -OsState Generalized -OsType Windows -ManagedDiskId $diskID to check if the image you used in creating the disk is Generalized; use: (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk Check the staus of the OSStae if its truly generalized.. You can always set a new computer name in as much the image used is generalized.

          – Paul Oyemakinwa
          Nov 15 '18 at 11:18













          Running (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk against my image tells me: OsState : Generalized

          – Jeffrey
          Nov 16 '18 at 10:24





          Running (Get-AzureRmImage -ResourceGroupName <rg-name> -ImageName <image-name>).StorageProfile.OsDisk against my image tells me: OsState : Generalized

          – Jeffrey
          Nov 16 '18 at 10:24











          0














          The point everyone is trying to make, from your description of the issue, it seems the Image was not generalized correctly or aspect of the generalization failed.



          The script work fine on my end, so the only issue is with the image. Screenshot



          Try another deployment from that image an see is you get the same computer name (WIN-I80O6J22ENS).



          If you get the same name that is a sure confirmation of issue with generalization.



          If the name changes it might mean that the machine you imaged has a policy that is not accepting the name 'dor' so the system is generating default name.



          Either way issue is not with the Powershell or Azure. Hope this helps.






          share|improve this answer
























          • I have tried another deployement from the Image, this time I got a computer name of 'WIN-5LTGQBDHG29'

            – Jeffrey
            Nov 15 '18 at 9:43











          • I have updated the main post with how the Image is being done, this used to work fine and my process hasn't changed, I think I read somewhere the other week that if you use an image to create a VM, then generalize and create and image from that, and keep doing that over and over, eventually it stops setting the computer name

            – Jeffrey
            Nov 15 '18 at 9:54











          • You should not specify an '/unattend' switch, i believe that is whats causing the issue. sysprep without that switch an you should be fine.

            – Hannel
            Nov 15 '18 at 15:36











          • But /unattend is needed to pass in the unattend.xml location? And I need this file to tell it what to set the TimeZone to.

            – Jeffrey
            Nov 16 '18 at 9:53











          • The file means that all OS configuration including Computername is going to be taken from that file. When it doesn't file computername in file, it just generates a default one.

            – Hannel
            Nov 16 '18 at 15:40
















          0














          The point everyone is trying to make, from your description of the issue, it seems the Image was not generalized correctly or aspect of the generalization failed.



          The script work fine on my end, so the only issue is with the image. Screenshot



          Try another deployment from that image an see is you get the same computer name (WIN-I80O6J22ENS).



          If you get the same name that is a sure confirmation of issue with generalization.



          If the name changes it might mean that the machine you imaged has a policy that is not accepting the name 'dor' so the system is generating default name.



          Either way issue is not with the Powershell or Azure. Hope this helps.






          share|improve this answer
























          • I have tried another deployement from the Image, this time I got a computer name of 'WIN-5LTGQBDHG29'

            – Jeffrey
            Nov 15 '18 at 9:43











          • I have updated the main post with how the Image is being done, this used to work fine and my process hasn't changed, I think I read somewhere the other week that if you use an image to create a VM, then generalize and create and image from that, and keep doing that over and over, eventually it stops setting the computer name

            – Jeffrey
            Nov 15 '18 at 9:54











          • You should not specify an '/unattend' switch, i believe that is whats causing the issue. sysprep without that switch an you should be fine.

            – Hannel
            Nov 15 '18 at 15:36











          • But /unattend is needed to pass in the unattend.xml location? And I need this file to tell it what to set the TimeZone to.

            – Jeffrey
            Nov 16 '18 at 9:53











          • The file means that all OS configuration including Computername is going to be taken from that file. When it doesn't file computername in file, it just generates a default one.

            – Hannel
            Nov 16 '18 at 15:40














          0












          0








          0







          The point everyone is trying to make, from your description of the issue, it seems the Image was not generalized correctly or aspect of the generalization failed.



          The script work fine on my end, so the only issue is with the image. Screenshot



          Try another deployment from that image an see is you get the same computer name (WIN-I80O6J22ENS).



          If you get the same name that is a sure confirmation of issue with generalization.



          If the name changes it might mean that the machine you imaged has a policy that is not accepting the name 'dor' so the system is generating default name.



          Either way issue is not with the Powershell or Azure. Hope this helps.






          share|improve this answer













          The point everyone is trying to make, from your description of the issue, it seems the Image was not generalized correctly or aspect of the generalization failed.



          The script work fine on my end, so the only issue is with the image. Screenshot



          Try another deployment from that image an see is you get the same computer name (WIN-I80O6J22ENS).



          If you get the same name that is a sure confirmation of issue with generalization.



          If the name changes it might mean that the machine you imaged has a policy that is not accepting the name 'dor' so the system is generating default name.



          Either way issue is not with the Powershell or Azure. Hope this helps.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 16:04









          HannelHannel

          55139




          55139













          • I have tried another deployement from the Image, this time I got a computer name of 'WIN-5LTGQBDHG29'

            – Jeffrey
            Nov 15 '18 at 9:43











          • I have updated the main post with how the Image is being done, this used to work fine and my process hasn't changed, I think I read somewhere the other week that if you use an image to create a VM, then generalize and create and image from that, and keep doing that over and over, eventually it stops setting the computer name

            – Jeffrey
            Nov 15 '18 at 9:54











          • You should not specify an '/unattend' switch, i believe that is whats causing the issue. sysprep without that switch an you should be fine.

            – Hannel
            Nov 15 '18 at 15:36











          • But /unattend is needed to pass in the unattend.xml location? And I need this file to tell it what to set the TimeZone to.

            – Jeffrey
            Nov 16 '18 at 9:53











          • The file means that all OS configuration including Computername is going to be taken from that file. When it doesn't file computername in file, it just generates a default one.

            – Hannel
            Nov 16 '18 at 15:40



















          • I have tried another deployement from the Image, this time I got a computer name of 'WIN-5LTGQBDHG29'

            – Jeffrey
            Nov 15 '18 at 9:43











          • I have updated the main post with how the Image is being done, this used to work fine and my process hasn't changed, I think I read somewhere the other week that if you use an image to create a VM, then generalize and create and image from that, and keep doing that over and over, eventually it stops setting the computer name

            – Jeffrey
            Nov 15 '18 at 9:54











          • You should not specify an '/unattend' switch, i believe that is whats causing the issue. sysprep without that switch an you should be fine.

            – Hannel
            Nov 15 '18 at 15:36











          • But /unattend is needed to pass in the unattend.xml location? And I need this file to tell it what to set the TimeZone to.

            – Jeffrey
            Nov 16 '18 at 9:53











          • The file means that all OS configuration including Computername is going to be taken from that file. When it doesn't file computername in file, it just generates a default one.

            – Hannel
            Nov 16 '18 at 15:40

















          I have tried another deployement from the Image, this time I got a computer name of 'WIN-5LTGQBDHG29'

          – Jeffrey
          Nov 15 '18 at 9:43





          I have tried another deployement from the Image, this time I got a computer name of 'WIN-5LTGQBDHG29'

          – Jeffrey
          Nov 15 '18 at 9:43













          I have updated the main post with how the Image is being done, this used to work fine and my process hasn't changed, I think I read somewhere the other week that if you use an image to create a VM, then generalize and create and image from that, and keep doing that over and over, eventually it stops setting the computer name

          – Jeffrey
          Nov 15 '18 at 9:54





          I have updated the main post with how the Image is being done, this used to work fine and my process hasn't changed, I think I read somewhere the other week that if you use an image to create a VM, then generalize and create and image from that, and keep doing that over and over, eventually it stops setting the computer name

          – Jeffrey
          Nov 15 '18 at 9:54













          You should not specify an '/unattend' switch, i believe that is whats causing the issue. sysprep without that switch an you should be fine.

          – Hannel
          Nov 15 '18 at 15:36





          You should not specify an '/unattend' switch, i believe that is whats causing the issue. sysprep without that switch an you should be fine.

          – Hannel
          Nov 15 '18 at 15:36













          But /unattend is needed to pass in the unattend.xml location? And I need this file to tell it what to set the TimeZone to.

          – Jeffrey
          Nov 16 '18 at 9:53





          But /unattend is needed to pass in the unattend.xml location? And I need this file to tell it what to set the TimeZone to.

          – Jeffrey
          Nov 16 '18 at 9:53













          The file means that all OS configuration including Computername is going to be taken from that file. When it doesn't file computername in file, it just generates a default one.

          – Hannel
          Nov 16 '18 at 15:40





          The file means that all OS configuration including Computername is going to be taken from that file. When it doesn't file computername in file, it just generates a default one.

          – Hannel
          Nov 16 '18 at 15:40


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279329%2fvm-created-from-image-with-azure-powershell-does-not-set-computername%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Full-time equivalent

          さくらももこ

          13 indicted, 8 arrested in Calif. drug cartel investigation