#Install ElasticBox Bootstrap $targetFolder = "$env:ProgramFiles\ElasticBox" $bootstrapScript = "$targetFolder\elasticbox-bootstrap.ps1" $taskName = "ElasticBox Bootstrap" if ( (Test-path -Path "$targetFolder") -eq $False) { New-Item -Path "$targetFolder" -Type directory } $script = @' #ElasticBox-Bootstrap $taskName = "ElasticBox Bootstrap" $targetFolder = "$env:ProgramFiles\ElasticBox" $content = "" $retries = 0 while (! $content -and $retries -lt 120) { $content = & "$env:ProgramFiles\VMware\VMware Tools\vmtoolsd.exe" --cmd="info-get guestinfo.elasticbox-data" | Out-String if (! $content) { $retries += 1 Start-Sleep -s 60 } } Set-Content -Path "$targetFolder\elasticbox-data.ps1" -Value $content powershell.exe -File "$targetFolder\elasticbox-data.ps1" '@ $script | Out-File $bootstrapScript schtasks /create /F /RU "NT AUTHORITY\SYSTEM" /RL HIGHEST /SC ONSTART /TN "$taskName" /TR "$env:SystemDrive\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File '$bootstrapScript'"