你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Invoke-AzUpgradeModulePlan

调用指定的模块升级计划。

语法

Invoke-AzUpgradeModulePlan
      [-Plan] <UpgradePlan[]>
      [-FileEditMode] <EditMode>
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

说明

调用指定的模块升级计划。

重要

如果 FileEditMode 参数设置为 ModifyExistingFiles,此步骤将具有破坏性。 此模式根据模块升级计划使文件编辑到位。 没有撤消操作。 始终确保有目标 PowerShell 脚本或模块的备份副本。

若要将升级的脚本内容保存到新文件中,请将原始文件保留为未修改,请使用 SaveChangesToNewFiles 参数指定

升级计划是通过运行 New-AzUpgradeModulePlan cmdlet 生成的。

示例

示例 1

以下示例调用名为 myModule 的 PowerShell 模块的升级计划,并将更新的文件内容保存到新文件中,使原始文件未修改。

# step 1: generate a plan and save it to a variable.
$plan = New-AzUpgradeModulePlan -FromAzureRmVersion 6.13.1 -ToAzVersion latest -DirectoryPath 'C:\Scripts\myModule'

# step 2: write the plan to the console to review the upgrade steps, warnings, and errors.
$plan

# step 3: run the automatic upgrade plan (saving updated scripts to new files) and collects the results in a variable.
$results = Invoke-AzUpgradeModulePlan -Plan $Plan -FileEditMode SaveChangesToNewFiles

# step 4: write the upgrade results to the console to review the result for each upgrade step.
$results

示例 2

以下示例调用名为 myModule 的 PowerShell 模块的升级计划,并就地修改现有文件。

# step 1: generate a plan and save it to a variable.
$plan = New-AzUpgradeModulePlan -FromAzureRmVersion 6.13.1 -ToAzVersion latest -DirectoryPath 'C:\Scripts\myModule'

# step 2: write the plan to the console to review the upgrade steps, warnings, and errors.
$plan

# step 3: run the automatic upgrade plan (modifying the files in place) and collects the results in a variable.
$results = Invoke-AzUpgradeModulePlan -Plan $Plan -FileEditMode ModifyExistingFiles

# step 4: write the upgrade results to the console to review the result for each upgrade step.
$results

参数

-Confirm

提示你在运行 cmdlet 之前进行确认。

类型:SwitchParameter
别名:cf
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-FileEditMode

指定文件编辑模式,以确定是否应就地执行升级计划、修改现有文件,或者是否应将更改保存到新文件。 指定 ModifyExistingFiles 以就地修改脚本文件,或 SaveChangesToNewFiles 保存新的 PowerShell 文件,使现有文件未修改。

类型:EditMode
接受的值:ModifyExistingFiles, SaveChangesToNewFiles
Position:2
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-Plan

指定要执行的升级计划步骤。 这是从 New-AzUpgradeModulePlan..

类型:UpgradePlan[]
Position:1
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-WhatIf

显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。

类型:SwitchParameter
别名:wi
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False