#Install ElasticBox Bootstrap $targetFolder = "$env:ProgramFiles\ElasticBox" $bootstrapScript = "$targetFolder\elasticbox-bootstrap.ps1" $taskName = "ElasticBox Bootstrap" $taskFile = "$targetFolder\elasticbox-task.xml" if ( (Test-path -Path "$targetFolder") -eq $False) { New-Item -Path "$targetFolder" -Type directory } $script = @' #ElasticBox-Bootstrap $taskName = "ElasticBox Bootstrap" $targetFolder = "$env:ProgramFiles\ElasticBox" foreach ($networkAdapterConfiguration in Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace Root/CIMV2 | Where {$_.IPEnabled -eq "True"}) { $dhcpServer = $networkAdapterConfiguration.DHCPServer break } if ($dhcpServer) { Set-Content -Path "$targetFolder\dhcpServer.txt" -Value $dhcpServer $webClient = New-Object System.Net.WebClient try { $content = $webClient.DownloadString("http://$dhcpServer/latest/user-data") } catch {} } if ($content) { Set-Content -Path "$targetFolder\elasticbox-data.ps1" -Value $content powershell.exe -File "$targetFolder\elasticbox-data.ps1" schtasks /delete /F /TN "$taskName" } '@ $script | Out-File $bootstrapScript $taskContent = @' 2015-01-15T00:04:04 ElasticBox PT1M false true S-1-5-18 HighestAvailable IgnoreNew true true true true false true false true true false false false P3D 7 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File "C:\Program Files\ElasticBox\elasticbox-bootstrap.ps1" '@ $taskContent | Out-File "$taskFile" schtasks /create /F /RU "NT AUTHORITY\SYSTEM" /TN "$taskName" /xml "$taskFile"