Windows 从Powershell中删除Microsoft.Powershell.Utility模块

Windows 从Powershell中删除Microsoft.Powershell.Utility模块,windows,powershell,Windows,Powershell,我正试图通过删除模块从Powershell中删除模块Microsoft.Powershell.Utility。命令成功了,但之后我仍然能够使用该模块中的命令,比如Format Hex。我错过了什么?我附上一个屏幕截图,显示行为 我的环境是Windows 10 Home 请注意,卸载模块Microsoft.Powershell.Utility是不明智的,因为它包含许多重要的cmdlet(请参见下面的列表) 模块命令自动重新出现的原因是PowerShell的,它会根据需要自动加载(导入)位于$en

我正试图通过删除模块从Powershell中删除模块Microsoft.Powershell.Utility。命令成功了,但之后我仍然能够使用该模块中的命令,比如Format Hex。我错过了什么?我附上一个屏幕截图,显示行为

我的环境是Windows 10 Home

请注意,卸载模块
Microsoft.Powershell.Utility
是不明智的,因为它包含许多重要的cmdlet
(请参见下面的列表)

模块命令自动重新出现的原因是PowerShell的,它会根据需要自动加载(导入)位于
$env:PSModulePath
中列出的目录中的模块

例如,通过将首选项变量设置为
None
,可以防止自动加载

请注意,对于,如果多个模块包含相同名称的命令:

  • 上次导入的任何模块都将“获胜”——除非您使用了
    导入模块-NoClobber
    ,否则导入失败

  • 您还可以使用特定于成员类型的
    -Cmdlet
    -Function
    -Alias
    -Variable
    参数,有选择地从模块导入

  • 您可以使用
    Import Module-Prefix
    为导入的成员附加前缀,以使其名称唯一,对于cmdlet和函数,前缀位于名词部分之前;e、 例如,
    Import模块-前缀栏…
    将名为
    Get-Foo
    的cmdlet重命名为
    Get-BarFoo

  • 最后,如果有重复的名称,您可以通过在成员名称前面加上模块名称来消除歧义,格式为
    \
    ;e、 例如,
    Microsoft.PowerShell.Utility\Format Hex


自Windows Powershell 5.1起,模块
Microsoft.Powershell.Utility
附带的cmdlet列表:

PS> (Get-Command -Module Microsoft.Powershell.Utility).Name
ConvertFrom-SddlString
Format-Hex
Get-FileHash
Import-PowerShellDataFile
New-Guid
New-TemporaryFile
Add-Member
Add-Type
Clear-Variable
Compare-Object
ConvertFrom-Csv
ConvertFrom-Json
ConvertFrom-String
ConvertFrom-StringData
Convert-String
ConvertTo-Csv
ConvertTo-Html
ConvertTo-Json
ConvertTo-Xml
Debug-Runspace
Disable-PSBreakpoint
Disable-RunspaceDebug
Enable-PSBreakpoint
Enable-RunspaceDebug
Export-Alias
Export-Clixml
Export-Csv
Export-FormatData
Export-PSSession
Format-Custom
Format-List
Format-Table
Format-Wide
Get-Alias
Get-Culture
Get-Date
Get-Event
Get-EventSubscriber
Get-FormatData
Get-Host
Get-Member
Get-PSBreakpoint
Get-PSCallStack
Get-Random
Get-Runspace
Get-RunspaceDebug
Get-TraceSource
Get-TypeData
Get-UICulture
Get-Unique
Get-Variable
Group-Object
Import-Alias
Import-Clixml
Import-Csv
Import-LocalizedData
Import-PSSession
Invoke-Expression
Invoke-RestMethod
Invoke-WebRequest
Measure-Command
Measure-Object
New-Alias
New-Event
New-Object
New-TimeSpan
New-Variable
Out-File
Out-GridView
Out-Printer
Out-String
Read-Host
Register-EngineEvent
Register-ObjectEvent
Remove-Event
Remove-PSBreakpoint
Remove-TypeData
Remove-Variable
Select-Object
Select-String
Select-Xml
Send-MailMessage
Set-Alias
Set-Date
Set-PSBreakpoint
Set-TraceSource
Set-Variable
Show-Command
Sort-Object
Start-Sleep
Tee-Object
Trace-Command
Unblock-File
Unregister-Event
Update-FormatData
Update-List
Update-TypeData
Wait-Debugger
Wait-Event
Write-Debug
Write-Error
Write-Host
Write-Information
Write-Output
Write-Progress
Write-Verbose
Write-Warning
请注意,卸载模块
Microsoft.Powershell.Utility
是不明智的,因为它包含许多重要的cmdlet
(请参见下面的列表)

模块命令自动重新出现的原因是PowerShell的,它会根据需要自动加载(导入)位于
$env:PSModulePath
中列出的目录中的模块

例如,通过将首选项变量设置为
None
,可以防止自动加载

请注意,对于,如果多个模块包含相同名称的命令:

  • 上次导入的任何模块都将“获胜”——除非您使用了
    导入模块-NoClobber
    ,否则导入失败

  • 您还可以使用特定于成员类型的
    -Cmdlet
    -Function
    -Alias
    -Variable
    参数,有选择地从模块导入

  • 您可以使用
    Import Module-Prefix
    为导入的成员附加前缀,以使其名称唯一,对于cmdlet和函数,前缀位于名词部分之前;e、 例如,
    Import模块-前缀栏…
    将名为
    Get-Foo
    的cmdlet重命名为
    Get-BarFoo

  • 最后,如果有重复的名称,您可以通过在成员名称前面加上模块名称来消除歧义,格式为
    \
    ;e、 例如,
    Microsoft.PowerShell.Utility\Format Hex


自Windows Powershell 5.1起,模块
Microsoft.Powershell.Utility
附带的cmdlet列表:

PS> (Get-Command -Module Microsoft.Powershell.Utility).Name
ConvertFrom-SddlString
Format-Hex
Get-FileHash
Import-PowerShellDataFile
New-Guid
New-TemporaryFile
Add-Member
Add-Type
Clear-Variable
Compare-Object
ConvertFrom-Csv
ConvertFrom-Json
ConvertFrom-String
ConvertFrom-StringData
Convert-String
ConvertTo-Csv
ConvertTo-Html
ConvertTo-Json
ConvertTo-Xml
Debug-Runspace
Disable-PSBreakpoint
Disable-RunspaceDebug
Enable-PSBreakpoint
Enable-RunspaceDebug
Export-Alias
Export-Clixml
Export-Csv
Export-FormatData
Export-PSSession
Format-Custom
Format-List
Format-Table
Format-Wide
Get-Alias
Get-Culture
Get-Date
Get-Event
Get-EventSubscriber
Get-FormatData
Get-Host
Get-Member
Get-PSBreakpoint
Get-PSCallStack
Get-Random
Get-Runspace
Get-RunspaceDebug
Get-TraceSource
Get-TypeData
Get-UICulture
Get-Unique
Get-Variable
Group-Object
Import-Alias
Import-Clixml
Import-Csv
Import-LocalizedData
Import-PSSession
Invoke-Expression
Invoke-RestMethod
Invoke-WebRequest
Measure-Command
Measure-Object
New-Alias
New-Event
New-Object
New-TimeSpan
New-Variable
Out-File
Out-GridView
Out-Printer
Out-String
Read-Host
Register-EngineEvent
Register-ObjectEvent
Remove-Event
Remove-PSBreakpoint
Remove-TypeData
Remove-Variable
Select-Object
Select-String
Select-Xml
Send-MailMessage
Set-Alias
Set-Date
Set-PSBreakpoint
Set-TraceSource
Set-Variable
Show-Command
Sort-Object
Start-Sleep
Tee-Object
Trace-Command
Unblock-File
Unregister-Event
Update-FormatData
Update-List
Update-TypeData
Wait-Debugger
Wait-Event
Write-Debug
Write-Error
Write-Host
Write-Information
Write-Output
Write-Progress
Write-Verbose
Write-Warning

不要那样做。“实用程序模块包含用于管理PowerShell基本功能的cmdlet。基本功能为什么要删除此功能?在执行任何激烈操作之前,您可能需要运行
Get Command-module Microsoft.PowerShell.Utility
——正如@Ben提到的,该模块中有许多非常重要/常用的命令(例如,
Get Date
Export Csv
Write Host
),而不仅仅是您提到的问题。请允许我向新来者提供标准建议:如果答案解决了您的问题,请单击大复选标记接受它(✓) 在它旁边,也可以选择向上投票(向上投票需要15点或更多的声誉点数)。如果您发现其他答案有帮助,请向上投票。接受(为此您将获得2点声誉点数)和向上投票有助于未来的读者。有关详细信息,请参阅。如果您的问题尚未完全回答,请提供反馈或。我正在尝试找到删除特定cmdlet的方法,但除了删除整个模块之外,我找不到其他方法。请不要这样做。“实用程序模块包含用于管理PowerShell基本功能的cmdlet。基本功能为什么要删除此功能?在执行任何激烈操作之前,您可能需要运行
Get Command-module Microsoft.PowerShell.Utility
——正如@Ben提到的,该模块中有许多非常重要/常用的命令(例如,
Get Date
Export Csv
Write Host
),而不仅仅是您提到的问题。请允许我向新来者提供标准建议:如果答案解决了您的问题,请单击大复选标记接受它(✓) 在它旁边,也可以选择向上投票(向上投票需要15点或更多的声誉点数)。如果您发现其他答案有帮助,请向上投票。接受(为此您将获得2点声誉点数)和向上投票有助于未来的读者。有关详细信息,请参阅。如果您的问题尚未完全回答,请提供反馈或。我正在尝试找到删除特定cmdlet的方法,但除了删除整个模块之外,我找不到其他方法。