More Related Content
Similar to 20150127 jawsug京王線 ec2_config (20)
More from Takayoshi Tanaka (20)
20150127 jawsug京王線 ec2_config
- 15. $ServiceName = 'Ec2Config'
$exePath = "C:¥tmp¥Ec2Install.exe"
Stop-Service $ServiceName –Force
# Ec2Install.exe はzipから解凍して自前のバケットに置いてある前提
Read-S3Object -BucketName mybucket -Key Ec2Install.exe -File $exePath
$param = @{
FilePath = $exePath
argument = [string]@(
"/norestart",
"/quiet"
)
}
Start-Process @param -Wait
# Configを編集してCloudWatch Logsへの送信を有効化しておくのを保証する
$configXml = "$env:ProgramFiles¥Amazon¥Ec2ConfigService¥Settings¥Config.xml"
[xml]$xml = Get-Content "$configXml"
$xml.get_DocumentElement().Plugins.Plugin `
| where Name -in "AWS.EC2.Windows.CloudWatch.PlugIn" `
| %{
$_.State = "Enabled"
$xml.Save($configXml)
}
Start-Service $ServiceName