通过


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

Invoke-AzUpgradeModulePlan

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

语法

Default (默认值)

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
默认值:None
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-FileEditMode

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

参数属性

类型:EditMode
默认值:None
接受的值:ModifyExistingFiles, SaveChangesToNewFiles
支持通配符:False
不显示:False

参数集

(All)
Position:2
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Plan

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

参数属性

类型:

UpgradePlan[]

默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:1
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

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

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:无线

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters