【发布时间】:2017-02-17 01:25:09
【问题描述】:
我正在尝试编写将发布到 Azure 虚拟机的 DSC 脚本。到目前为止,我已经能够完成一些基本的事情,比如启用 Windows 功能和创建目录。但现在我想在 azure 虚拟机上安装 Chocolatey。所以这是我的脚本
configuration IIsAspNetInstall
{
Import-DscResource -ModuleName cChoco
node "localhost"
{
WindowsFeature IIS
{
Ensure="present"
Name="web-server"
}
WindowsFeature InstallDotNet45
{
Name = "Web-Asp-Net45"
Ensure = "Present"
}
WindowsFeature InstallIISConsole
{
Name = "Web-Mgmt-Console"
Ensure = "Present"
}
File WebsiteFolderCreate
{
Ensure = "Present"
Type = "Directory"
DestinationPath = "C:\inetpub\wwwroot\AdventureWorks"
Force = $true
}
cChocoInstaller installChoco
{
InstallDir = "C:\choco"
}
}
}
在我的本地计算机上,我使用的是 PowerShell 5.0,在 ISE 中,Import-DscResource 下出现红色波浪线,表示找不到 moduleName cChoco。我知道这是一个关键字,应该在配置部分有效。当我做Publish-AzureVMDscConfiguration 时,我得到一个解析错误
+ Import-DscResource -ModuleName cChoco
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Could not find the module 'cChoco'.
【问题讨论】:
-
机器上是否安装了模块 cChoco?错误消息非常清楚地说明了问题所在。
-
我以为 Import-DscResource 会导入它,但后来我发现我可以使用 Install-Module 并安装模块。感谢您指出。
标签: powershell azure powershell-dsc