You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查询未安装PowerShell模块的目标PowerShell版本?

如何在安装前查询PowerShell模块支持的PowerShell版本

当Find-Module -Tag PSEdition_Desktop/Core方法因模块作者未填写标签而失效时,你可以尝试以下几种方法:

  • 查看模块的版本兼容属性
    使用Find-Module结合属性筛选,直接读取模块清单中定义的版本要求:

    Find-Module -Name AzureAD | Select-Object Name, PowerShellVersion, CompatiblePSEditions
    
    • PowerShellVersion:显示模块要求的最低PowerShell版本
    • CompatiblePSEditions:明确标注模块支持的PS版本分支(Desktop对应PowerShell 5.x,Core对应PowerShell 7+)
  • 查看模块的详细描述与发布说明
    通过Format-List查看模块的完整元数据,描述或发布说明中通常会注明版本支持信息:

    Find-Module -Name AzureAD | Format-List *
    

    重点关注Description、ReleaseNotes字段,很多模块会在这里明确说明仅支持PowerShell Desktop或Core。

  • 检查模块的依赖项
    模块的依赖框架能间接反映其支持的PS版本:

    Find-Module -Name AzureAD | Select-Object -ExpandProperty Dependencies
    
    • 若依赖.NET Framework相关组件,通常仅支持PowerShell Desktop
    • 若依赖.NET Core/.NET 5+组件,则支持PowerShell Core
  • 临时安装并读取模块清单
    如果以上方法仍无法确定,可将模块临时安装到测试目录,直接读取模块的psd1清单文件获取准确信息:

    # 安装到临时目录
    Install-Module -Name AzureAD -DestinationPath C:\Temp\PSModules -Force -SkipPublisherCheck
    # 提取版本兼容信息
    Get-Content C:\Temp\PSModules\AzureAD\AzureAD.psd1 | Select-String -Pattern 'PowerShellVersion|CompatiblePSEditions'
    # 验证后删除临时文件
    Remove-Item C:\Temp\PSModules -Recurse -Force
    

内容的提问来源于stack exchange,提问作者Tiago Duarte

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 13:53:23