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

如何设置计算机配置创作环境

PowerShell 模块 GuestConfiguration 自动执行创建自定义内容的过程,包括:

  • 创建计算机配置内容项目 (.zip)
  • 验证包是否符合要求
  • 在本地安装计算机配置代理以进行测试
  • 验证包是否可用于审核计算机中的设置
  • 验证包是否可用于配置计算机中的设置
  • 将包发布到 Azure 存储
  • 创建策略定义
  • 发布策略

版本 3.4.2 中引入了对通过计算机配置应用配置的支持。

基本要求

可以安装模块的操作系统:

  • Ubuntu 20
  • Windows操作系统

该模块可以安装在运行 PowerShell 7.x 的计算机上。 为操作系统安装下表中列出的 PowerShell 版本。

操作系统 所需的最低 PowerShell 版本 安装
Windows操作系统 7.1.3 在 Windows 上安装 PowerShell
Ubuntu 20 7.2.4 在 Ubuntu 上安装 PowerShell

对于 Linux,以下 shell 脚本下载并安装 PowerShell 7.2.4。

###################################
# Prerequisites

# Update the list of packages
sudo apt-get update

# Install pre-requisite packages.
sudo apt-get install -y wget

# Download the PowerShell package file
wget https://github.com/PowerShell/PowerShell/releases/download/v7.2.4/powershell_7.2.4-1.deb_amd64.deb

###################################
# Install the PowerShell package
sudo dpkg -i powershell_7.2.4-1.deb_amd64.deb

# Resolve missing dependencies and finish the install (if necessary)
sudo apt-get install -f

# Delete the downloaded package file
rm powershell_7.2.4-1.deb_amd64.deb

# Switch the user to root before launching PowerShell
sudo su

# Start PowerShell
pwsh

GuestConfiguration 模块需要以下软件:

  • Azure PowerShell 5.9.0 或更高版本。 所需的 Az PowerShell 模块随 GuestConfiguration 模块一起自动安装,也可以按照这些说明进行操作。

若要在 Windows 或 Linux 上安装 GuestConfiguration 模块,请在 PowerShell 7 中运行以下命令。

# Install the machine configuration DSC resource module from PowerShell Gallery
Install-Module -Name GuestConfiguration

验证模块是否已导入:

# Get a list of commands for the imported GuestConfiguration module
Get-Command -Module GuestConfiguration

在 Windows 上安装 PSDesiredStateConfiguration 模块,请在 PowerShell 7 中运行以下命令。

# Install PSDesiredStateConfiguration version 2.0.7 (the stable release)
Install-Module -Name PSDesiredStateConfiguration -RequiredVersion 2.0.7
Import-Module -Name PSDesiredStateConfiguration

在 Linux 上安装 PSDesiredStateConfiguration 模块,请在 PowerShell 7 中运行以下命令。

# Install PSDesiredStateConfiguration prerelease version 3.0.0
Install-Module -Name PSDesiredStateConfiguration -RequiredVersion 3.0.0-beta1 -AllowPrerelease
Import-Module -Name PSDesiredStateConfiguration

验证模块是否已导入:

# Get a list of commands for the imported PSDesiredStateConfiguration module
Get-Command -Module PSDesiredStateConfiguration

下一步