get-windowsfeature on vhd file

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of Stephen Owen Stephen Owen 1 year, 11 months ago.

  • Author
    Posts
  • #21286
    Profile photo of FredL
    FredL
    Participant

    Hi

    I am just starting out learning windows server and hyper-v.I do know some powershell since before. I am using windows 8.1 and have downloaded a vhd-file with windows server 2012 r2 and installed in hyper-v.

    However when I run this from my win 8.1 computer

     get-windowsfeature -vhd 'Mywinserver2012.vhd' 

    I get this error message:

    get-windowsfeature : The target of the specified cmdlet cannot be a Windows client-based operating system.
    At line:1 char:1
    + get-windowsfeature -vhd 'Mywinserver2012.vhd'
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : DeviceError: (localhost:String) [Get-WindowsFeature], Exception
    + FullyQualifiedErrorId : WindowsClient_NotSupported,Microsoft.Windows.ServerManager.Commands.GetWindowsFeatureCommand

  • #21287
    Profile photo of Don Jones
    Don Jones
    Keymaster

    The cmdlet is, for some reason, not seeing the VHD as a target. Have you tried doing this same thing from a server host OS, against the server VHD?

  • #21289
    Profile photo of FredL
    FredL
    Participant

    Thank you very much for your reply. I haven't tried from a server OS yet, right now i only have access to my client computer but I will be sure to try it from a server OS as fast as I can.

    Reading the help now I see this, Does this means that the vhd-file gets "mounted" every time, and actually it is my localcomputer that is the "target" computer?

    -Vhd
    Specifies the path to an offline VHD. The path can either point to a VHD file, or to a location on which the VHD is already mounted by using Deployment Image Servicing and Management (DISM) tools.
    The VHD can be on a local disk on the target computer, or on a network shared folder. If the VHD is in a network shared folder, then the value of this parameter is a UNC path to the VHD. In this case, the computer account of the computer that you are using to mount the VHD must have read and write permissions (Read/Write permissions in the File Sharing dialog box, or Full Control on the Security tab of the folder Properties dialog box) on the shared folder, or the VHD will not be accessible. Local loopback UNC paths are not supported. Use either of the following formats for the computer account: DOMAIN\SERVERNAME$ or SERVERNAME$.
    Add the ComputerName parameter to specify the target computer you want to use to mount the VHD. [b]If the ComputerName parameter is not specified, then the local computer is used.[/b] The computer that you are using to mount the VHD must be running Windows Server 2012 R2. Any local path, such as D:\myFolder, that is specified by using this parameter is always relative to the target computer.

  • #21296
    Profile photo of Don Jones
    Don Jones
    Keymaster

    The help (which I read earlier) implies that what you're trying should, in fact, work. So yes, it is using your local computer to mount the VHD, but it should be checking the windows feature IN the VHD, and the fact that it's complaining about it not being a client computer is what suggests it isn't working the way it's advertised.

    The fact that it doesn't work means we should attempt to troubleshoot, which is why I suggested running it on a server host OS.

    Your other option would be to open a ticket with Microsoft product support, since they're the only ones who can look at the code and tell you if it should in fact work.

  • #21304
    Profile photo of FredL
    FredL
    Participant

    Don, thanks again for taking the time to answer(how sick that the Don Jones is answering my question).

    I copied the file to the local drive of a new Win2012 R2-server. And indeed get-windowsfeature worked, so nothing seems to be wrong
    with the file.

    However, you write "it is using your local computer to mount the VHD" (which is win 8.1). And in the helpfile it says
    "If the ComputerName parameter is not specified, then the local computer is used. The
    computer that you are using to mount the VHD must be running Windows Server 2012 R2."
    So I hope you understand if I am a little confused.

  • #21327
    Profile photo of Stephen Owen
    Stephen Owen
    Participant

    [blockquote]"If the ComputerName parameter is not specified, then the local computer is used. The
    computer that you are using to mount the VHD must be running Windows Server 2012 R2."
    So I hope you understand if I am a little confused.[/blockquote]

    I think what is happening here is that the path to the file was somehow incorrect, and so the command was attempting to run on your local system. However, since your local system is running Windows 8.1, you can't use that cmdlet (it's for servers only).

    I bet if you tried the command again from the remote location with a fully qualified file name, or if you copied it locally and ran the command with the file name dot-sourced like this '.\NameofYour.Vhd' it would work.

You must be logged in to reply to this topic.