【问题标题】:Unable to get Service Fabric PowerShell module无法获取 Service Fabric PowerShell 模块
【发布时间】:2020-09-26 04:54:38
【问题描述】:

我在 Windows Server 2016 Datacenter 上运行,但无法获取 Connect-ServiceFabricCluster 等 Service Fabric 命令行开关。

Documentation 说:Service Fabric PowerShell 模块随 Service Fabric SDK、运行时和工具一起安装。

  • 我正在使用 Visual Studio 2019
  • 我按照here 的说明从 Web 平台安装程序中卸载并重新安装了 Service Fabric SDK,并重新启动了我的系统。

我还能尝试什么?它在我使用 Windows 10 的其他系统中工作。我可以从另一个正在工作的系统中导出模块并在此处导入吗?

【问题讨论】:

  • Get-Command *Fabric* -All 有什么作用,它列出了什么吗?
  • 它列出了来自模块 Az.ServiceFabric 和 AzureRm.ServiceFabric 的不同命令行开关。在工作系统中,它也来自我感兴趣的模块 ServiceFabric(列出的所有命令行开关here)。
  • 我尝试了所有建议,但在启动 PowerShell 时仍需要手动加载 ServiceFabric PowerShell 模块。我也收到此警告:使用 WinPSCompatSession 远程会话在 Windows PowerShell 中加载模块 servicefabric;请注意,此模块的所有命令输入和输出都将是反序列化对象。如果您想将此模块加载到 PowerShell 中,请使用“Import-Module -SkipEditionCheck”语法。

标签: powershell azure-service-fabric powershell-5.0


【解决方案1】:

不确定您是如何安装服务结构 sdk 的;我自己尝试过,能够在列表中找到 Connect-ServiceFabricCluster。我可以建议两种最简单的安装方法。

A.带巧克力包

choco install MicrosoftAzure-ServiceFabric-CoreSDK --source webpi --confirm

B.单独安装

安装 visual c++ 2012 SP1 可再发行包

调用-WebRequest "http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU1/vcredist_x64.exe" -OutFile "C:\vcredist.exe" -UseBasicParsing; \ 启动进程 "C:\vcredist.exe" -ArgumentList '/install', '/passive' -NoNewWindow -Wait; \ rm "C:\vcredist.exe"

安装 Service Fabric 运行时

调用-WebRequest “http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabric.6.0.232.9494.exe” -OutFile "C:\ServiceFabricRuntime.exe" -UseBasicParsing; \ 启动进程 "C:\ServiceFabricRuntime.exe" -ArgumentList '/AcceptEULA', '/QUIET' -NoNewWindow -Wait; \ rm "C:\ServiceFabricRuntime.exe"

安装 Service Fabric SDK

调用-WebRequest “http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabricSDK.2.8.232.msi” -OutFile "C:\ServiceFabricSDK.msi" -UseBasicParsing; \ 启动进程 "msiexec" -ArgumentList '/i', 'C:\ServiceFabricSDK.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -等待; \ rm "C:\ServiceFabricSDK.msi"

这是输出

$> Get-Command *ServiceFabricCluster* -All

【讨论】:

  • 我做了 B,而且 Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser 成功了
【解决方案2】:

就我而言,我使用 PowerShell 7.x 作为我的默认 PowerShell 版本。显然,ServiceFabric PowerShell 模块仅与该版本部分兼容,因此不会自动加载。在我使用 PowerShell 5.x 管理 ServiceFabric 后,该模块在 PowerShell 启动时加载并准备好使用。

【讨论】:

  • 这里也一样。我使用Import-Module ServiceFabric -UseWindowsPowerShell 通过remoting 导入它。
  • @devmb 谢谢,这是我唯一能找到这个解决方案的地方
猜你喜欢
  • 2021-09-14
  • 2023-03-03
  • 1970-01-01
  • 2016-09-28
  • 2019-06-16
  • 2017-09-30
  • 2019-07-06
  • 1970-01-01
  • 2019-03-23
相关资源
最近更新 更多