Is it possible to/how do you stop powershell using certain cmdlets?

前端 未结 2 2033
栀梦
栀梦 2021-01-15 16:09

Powershell is clearly a lot better than cmd but it hides basic functionality. I normally use it to figure out how to use commands that I want in scripts but it breaks a lar

2条回答
  •  攒了一身酷
    2021-01-15 16:27

    There is no need to turn off cmdlets in powershell as that would destroy the very reason for having it.

    Most of the "normal" stuff is there anyway, which you can find by using the get-alias command.

    C:\> get-alias
    
    CommandType     Name
    -----------     ----
    Alias           % -> ForEach-Object
    Alias           ? -> Where-Object
    Alias           ?? -> Invoke-NullCoalescing
    Alias           ac -> Add-Content
    Alias           asnp -> Add-PSSnapin
    Alias           cat -> Get-Content
    Alias           cd -> Set-Location
    Alias           chdir -> Set-Location
    .....
    ..... AND A WHOLE LOT MORE!
    

    If you are missing a command that you really, really want to have, then you can easily add a new alias:

    Set-Alias python2 "C:\Python27\python.exe"
    

    In order to avoid having to do this every single time, you can simply add this into your startup profile. Just type in $PROFILE into the command prompt and it will show you the file path. If it doesn't exist, simply create it, and any powershell commands you add to the top will be automatically invoked when you start a new session.

    And last thing. All of the commands are documented, and you can get to them easily using just two.

    Just type this into your command prompt and you will be on your way to Powershell enlightenment!

    get-help get-command
    
    get-command -noun Item
    get-command -verb get
    

提交回复
热议问题