PowerShell で DSC を使用してサービスを展開しようとしています。Microsoft Documentationによると、サービス リソースには次の設定可能なプロパティがあります。
- 名前
- 確認
- ビルトインアカウント
- 資格情報
- 依存関係
- 引数
- スタートアップの種類
- 州
DSC 構成でサービスを定義しましたが、エラーが発生します。
これは私のコードです:
Configuration ServiceDeployConfig
{
param(
[string[]]$ComputerName="localhost",
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $serviceDeployPath,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $serviceName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $serviceDisplayName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $serviceExecutable,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $serviceUserame,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $servicePassword
)
Node $ComputerName
{
File serviceFiles
{
Ensure = "Present"
SourcePath = "\\Path\to\exe\$serviceExecutable"
DestinationPath = $serviceDeployPath
}
Service serviceInstall
{
Ensure = "Present"
Name = $serviceName
Credential = New-Object System.Management.Automation.PSCredential ($serviceUserame, (ConvertTo-SecureString $servicePassword -AsPlainText -Force))
DependsOn = "[File]serviceFiles"
Arguments = "-binaryPathName $serviceDeployPath\$serviceExecutable", "-displayName $serviceDisplayName"
StartupType = Automatic
Status = Start
}
}
}
ここに私が得るエラーがあります:
At line:43 char:13
+ Ensure = "Present"
+ ~~~~~~
The member 'Ensure' is not valid. Valid members are 'DependsOn', 'Name', 'State', 'StartupType', 'BuiltInAccount', 'Credential'. Please update your script and try again.
At line:47 char:13
+ Arguments = "-binaryPathName $serviceDeployPath\$serviceExecutable", ...
+ ~~~~~~~~~
The member 'Arguments' is not valid. Valid members are 'DependsOn', 'Name', 'State', 'StartupType', 'BuiltInAccount', 'Credential'. Please update your script and try again.
At line:49 char:13
+ Status = Start
+ ~~~~~~
The member 'Status' is not valid. Valid members are 'DependsOn', 'Name', 'State', 'StartupType', 'BuiltInAccount', 'Credential'. Please update your script and try again.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidInstanceProperty
私は GitHub ( https://gist.github.com/grenade/7677021 ) でこの例をたどったので、自分のコードに関して正しい道をたどっていることがわかります。
ダウンロードする必要がある新しいバージョンの DSC はありますか? ドキュメントリストにあるが存在しないように見えるプロパティを使用するときに、どのように機能させるのですか?