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

前端 未结 2 2030
栀梦
栀梦 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:38

    I just realised the answer to my question was buried in the comments to the other answer:

    To remove a cmdlet in powershell you run

    Remove-Item alias:something.

    I can confirm you can do this by using the profile mentioned in Josh's post, however there are a couple more steps:

    By default you cant run scripts in powershell. You have to change this using set-ExecutionPolicy.

    I changed this by using an admin powershell and typing

    set-executionpolicy bypass
    

    This will let you run any script you like

    Then in my profile script I have lines like:

    Remove-Item -force alias:sc
    

    You wont see errors from this script when it runs and it wont do anything unless you have force.

提交回复
热议问题