Поделиться через


Remove-Alias

Remove an alias from the current session.

Синтаксис

Default (по умолчанию)

Remove-Alias
    [-Name] <String[]>
    [-Scope <String>]
    [-Force]
    [<CommonParameters>]

Описание

The Remove-Alias cmdlet removes an alias from the current PowerShell session. To remove an alias with the Option property set to ReadOnly, use the Force parameter.

The Remove-Alias cmdlet was introduced in PowerShell 6.0.

Примеры

Example 1 - Remove an alias

This example removes an alias named del that represents the Remove-Item cmdlet.

Remove-Alias -Name del

Example 2 - Remove all non-Constant aliases

This example removes all aliases from the current PowerShell session, except for aliases with the Options property set to Constant. After the command is run, the aliases are available in other PowerShell sessions or new PowerShell sessions.

Get-Alias | Where-Object { $_.Options -ne "Constant" } | Remove-Alias -Force

Get-Alias gets all the aliases in the PowerShell session and sends the objects down the pipeline. Where-Object uses a script block, and the automatic variable ($_) and Options property represent the current pipeline object. The -ne (not equal) operator selects objects that don't have an Options value set to Constant. Remove-Alias uses the Force parameter to remove aliases, including read-only aliases, from the PowerShell session. The Force parameter can't remove Constant aliases.

Параметры

-Force

Indicates that the cmdlet removes an alias, including aliases with the Option property set to ReadOnly. The Force parameter can't remove an alias with an Option property set to Constant.

Свойства параметра

Тип:SwitchParameter
Default value:False
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-Name

Specifies the name of the alias to remove.

Свойства параметра

Тип:

String[]

Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position:0
Обязательно:True
Значение из конвейера:True
Значение из конвейера по имени свойства:True
Значение из оставшихся аргументов:False

-Scope

Affects only the aliases in the specified scope. The default scope is Local. For more information, see about_Scopes.

The acceptable values for this parameter are:

  • Global
  • Local
  • Script
  • A number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent)

Свойства параметра

Тип:String
Default value:Local
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Входные данные

String

You can pipe an alias object to this cmdlet.

Выходные данные

None

This cmdlet returns no output.

Примечания

Changes only affect the current scope. To remove an alias from all sessions, add a Remove-Alias command to your PowerShell profile.

For more information, see about_Aliases.