安装 Microsoft Graph PowerShell SDKInstall the Microsoft Graph PowerShell SDK

Microsoft Graph PowerShell SDK 发布在 PowerShell 库中。The Microsoft Graph PowerShell SDK is published on the PowerShell Gallery. 您可以使用以下命令在 PowerShell Core 或 Windows PowerShell 中安装 SDK。You can install the SDK in PowerShell Core or Windows PowerShell using the following command.

Install-Module Microsoft.Graph

(可选)您可以使用参数更改安装的默认范围 -ScopeOptionally, you can change the default scope of the installation using the -Scope parameter. 这需要管理员权限。This requires admin permissions.

Install-Module Microsoft.Graph -Scope AllUsers

重要

在一个版本的 PowerShell 中安装 SDK 并不会为另一个版本安装 SDK。Installing the SDK in one version of PowerShell does not install it for the other. 请务必在您打算在其中使用安装命令的 PowerShell 版本中运行安装命令。Be sure to run the installation command inside the version of PowerShell you intend to use it in.

验证安装Verify installation

安装完成后,您可以使用以下命令验证已安装的版本。After the installation completes, you can verify the installed version with the following command.

Get-InstalledModule Microsoft.Graph

输出中的版本应与在 PowerShell 库上发布的最新版本相匹配。The version in the output should match the latest version published on the PowerShell Gallery. 现在,你已准备好使用 SDK。Now you're ready to use the SDK.

更新 SDKUpdating the SDK

您可以使用以下命令更新 SDK 及其所有依赖项。You can update the SDK and all of its dependencies using the following command.

Update-Module Microsoft.Graph

卸载 SDKUninstalling the SDK

首先,使用以下命令卸载主模块。First, use the following command to uninstall the main module.

Uninstall-Module Microsoft.Graph

然后,通过运行以下命令来删除所有依赖项模块。Then, remove all of the dependency modules by running the following commands.

Get-InstalledModule Microsoft.Graph.* | %{ if($_.Name -ne "Microsoft.Graph.Authentication"){ Uninstall-Module $_.Name } }
Uninstall-Module Microsoft.Graph.Authentication

提供反馈Provide feedback

我们欢迎你的反馈!We welcome feedback! 请在 SDK GitHub 存储库中提供任何反馈或报告任何问题。Please provide any feedback or report any problems on the SDK GitHub repository.