locked
Unable to use powershell commands RRS feed

  • Question

  • When I try to use commands in powershell like clear, cls, Clear-Host, Get-Host, and others it will error out. Only some commands work like Get-Help.  Is there a way to resolve this?
    Tuesday, November 10, 2015 2:06 PM

Answers

  • If you get a certificate error then please make sure WIF is installed and try again.

    dism /online /enable-feature /featureName:Windows-Identity-Foundation
    To install PowerShell and al it's features execute the following.
    dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell /all

    Also make sure .net 2.0 is installed.

    dism /online /enable-feature /featurename:NetFx2-ServerCore
    dism /online /enable-feature /featurename:NetFx2-ServerCore-WOW64

    Try to disable it by replacing enable with disable, good luck.



    Cheers,

    Ruud
    Twitter:    Blog: www.ruudborst.nl  LinkedIn:    
    Note: Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.




    • Edited by Ruud BorstMVP Tuesday, November 10, 2015 6:55 PM
    • Proposed as answer by Elaine Jing Thursday, November 12, 2015 2:50 AM
    • Marked as answer by Elaine Jing Monday, November 16, 2015 3:12 AM
    Tuesday, November 10, 2015 5:34 PM

All replies

  • I wouldn't be bad to have a more detailed error description. What is the error message you get?
    Tuesday, November 10, 2015 2:31 PM
  • PS c:\Windows\system32\> Get-Host

    Get-Host : The term 'Get-Host' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    
    At line:1 char:1
    
    + Get-Host
    
    +~~~~~~~~
    
    +CategoryInfo
    : ObjectNotFound: (Get-Host:String) [], CommandNotFoundException
    
    + FullyQualifiedErrorId
    : CommandNotFoundException



    Tuesday, November 10, 2015 2:48 PM
  • What version of PowerShell are you currently running?

    Tuesday, November 10, 2015 2:51 PM
  • Looks like your PowerShell framework is corrupt. Reinstall with WMF 4.0v.

    Cheers,

    Ruud
    Twitter:    Blog: www.ruudborst.nl  LinkedIn:    
    Note: Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Proposed as answer by Mike Laughlin Tuesday, November 10, 2015 3:39 PM
    Tuesday, November 10, 2015 3:20 PM
  • I am running PowerShell 4.0 I believe. It is Server 2012 and I usually get the version by running Get-Host.
    Tuesday, November 10, 2015 3:29 PM
  • I am running PowerShell 4.0 I believe. It is Server 2012 and I usually get the version by running Get-Host.

    $PSVersionTable output?


    Tuesday, November 10, 2015 3:31 PM
  • Thanks Mike. It is indeed PSVersion 4.0.

    I tried to install the Windows Management 4.00 and an error returned.

    Windows Update Standalone Installer

    Installer encountered an error: 0x80096002

    The certificate for the signer of the message is invalid or not found.

    Tuesday, November 10, 2015 3:36 PM
  • Yeah, seems like a bad upgrade. I'd try removing WMF4 and starting over again.

    Tuesday, November 10, 2015 3:36 PM
  • I have Sharepoint on this server. I am surprised to see that .net 4.5 is not installed on this server. I would think that it would be there since PowerShell uses the framework. Let me give that a try.
    Tuesday, November 10, 2015 3:42 PM
  • Nevermind. I can see it in Server Manager but not add and remove programs. I am new to Server 2012.
    Tuesday, November 10, 2015 3:43 PM
  • I might be missing something. 

    Remove-WindowsFeature is not working on this server 2012 installation. Also, this feature does not seem visible in Server Manager.  Is there another way to remove and reinstall it?

    Tuesday, November 10, 2015 4:40 PM
  • If you get a certificate error then please make sure WIF is installed and try again.

    dism /online /enable-feature /featureName:Windows-Identity-Foundation
    To install PowerShell and al it's features execute the following.
    dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell /all

    Also make sure .net 2.0 is installed.

    dism /online /enable-feature /featurename:NetFx2-ServerCore
    dism /online /enable-feature /featurename:NetFx2-ServerCore-WOW64

    Try to disable it by replacing enable with disable, good luck.



    Cheers,

    Ruud
    Twitter:    Blog: www.ruudborst.nl  LinkedIn:    
    Note: Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.




    • Edited by Ruud BorstMVP Tuesday, November 10, 2015 6:55 PM
    • Proposed as answer by Elaine Jing Thursday, November 12, 2015 2:50 AM
    • Marked as answer by Elaine Jing Monday, November 16, 2015 3:12 AM
    Tuesday, November 10, 2015 5:34 PM
  • Unfortunately, this was not the fix for me.  I tried to apply these steps and still getting the error. ServerCore is not recognized. I ran this command and it works but basic commands still are not recognized.

    dism /online /enable-feature /featurename:netfx3 /all /source:E:\sources\sxs

    Monday, November 16, 2015 1:48 PM