none
Hyper-V Role Install During OSD

    Question

  • Hello all,

    I have a captured Windows Server 2012 R2 deployment, and during my TS I have a "Run Command Line" task to install Hyper-V role, and I'm using the following code:

    Powershell.exe -Command "& {&'Install-WindowsFeature' –Name Hyper-V -IncludeManagementTools -Restart}"

    According to several people's blog, the above line should work...well, it isn't.

    Here's the error message I get after the OS is deployed:

    Executing command line: Run command line
    & : The term 'Install-WindowsFeature' is not recognized as the name of a cmdlet, function, script file, or operable
    At line:1 char:5
    + & {&'Install-WindowsFeature' -Name Hyper-V -IncludeManagementTools -R ...
    +     ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-WindowsFeature:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    I don't know what I'm missing here.

    Thanks!


    • Edited by GonzEd Friday, October 28, 2016 1:11 AM
    Friday, October 28, 2016 1:10 AM

Answers

  • You are doing the above in WinPE so it can't work. Move your task to after the Setup Windows and ConfigMgr task so that it runs in deployed OS.

    Jason | http://blog.configmgrftw.com | @jasonsandys

    • Proposed as answer by Torsten [MVP]MVP Friday, October 28, 2016 1:54 PM
    • Marked as answer by GonzEd Friday, October 28, 2016 2:33 PM
    Friday, October 28, 2016 1:04 PM

All replies

  • It looks like your command is launching in 32-bit PowerShell, which doesn't contain the Install-WindowsFeature Cmdlet.

    Try to tick the "Disable 64-bit file System redirection" Checkbox.


    Simon Dettling | msitproblog.com | @SimonDettling

    Friday, October 28, 2016 12:02 PM
  • You are doing the above in WinPE so it can't work. Move your task to after the Setup Windows and ConfigMgr task so that it runs in deployed OS.

    Jason | http://blog.configmgrftw.com | @jasonsandys

    • Proposed as answer by Torsten [MVP]MVP Friday, October 28, 2016 1:54 PM
    • Marked as answer by GonzEd Friday, October 28, 2016 2:33 PM
    Friday, October 28, 2016 1:04 PM
  • You are doing the above in WinPE so it can't work. Move your task to after the Setup Windows and ConfigMgr task so that it runs in deployed OS.

    Jason | http://blog.configmgrftw.com | @jasonsandys

    That did it, thanks!

    Friday, October 28, 2016 2:33 PM