PowerShell モジュール GuestConfiguration では、次のようなカスタム コンテンツの作成プロセスを自動化します。
- マシン構成コンテンツ成果物 (
.zip
) を作成する - パッケージが要件を満たしていることを検証する
- テスト用にマシン構成エージェントをローカルにインストールする
- パッケージを使用してマシンの設定を監査できることを検証する
- パッケージを使用してマシンの設定を構成できることを検証する
- Azure Storage へのパッケージの公開
- ポリシー定義の作成
- ポリシーの発行
マシン構成を使った構成の適用のサポートは、バージョン 3.4.2 で導入されています。
基本要件
モジュールをインストールできるオペレーティング システム:
- Ubuntu 20
- ウィンドウズ
モジュールは、PowerShell 7.x を実行しているマシンにインストールできます。 次の表に示す PowerShell のバージョンをオペレーティング システムにインストールします。
オペレーティングシステム (OS) | 最低限必要な PowerShell バージョン | 取り付け |
---|---|---|
ウィンドウズ | 7.1.3 |
Windows への PowerShell のインストール |
Ubuntu 20 | 7.2.4 |
Ubuntu への PowerShell のインストール |
Linux の場合、次のシェル スクリプトは 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 モジュールと一緒に自動的にインストールされます。または、次の手順に従うこともできます。
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
PowerShell ギャラリーから PSDesiredStateConfiguration モジュールをインストールする
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