GCE Windows启动脚本 [英] GCE Windows startup script

查看:56
本文介绍了GCE Windows启动脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的问题,即我的 windows-startup-script-ps1 在启动时没有按照

I am facing a strange problem where my windows-startup-script-ps1 is not running at startup as per official link. This corresponds to a PowerShell script as the name indicates. Having looked further into Serial Port logs I found that the error is:

术语'gs://mybucket/metadata.ps1'不被识别为cmdlet,函数,脚本文件或可运行程序的名称.检查名称的拼写,或者是否包含路径,请验证路径正确,然后重试.

The term 'gs://mybucket/metadata.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

我尝试给它提供Cloud Storage API对象路径,但仍然出现此错误.我的Compute Engine VM具有只读的Cloud Storage访问权限,我通过在Compute Engine VM中运行 gsutil 进行了验证.谁能阐明这个问题?

I tried giving it the Cloud Storage API object path but it's still getting this error. My Compute Engine VM has read-only Cloud Storage access and I verified it by running gsutil inside my Compute Engine VM. Can anyone shed some light on this issue?

Function Write-SerialPort ([string] $message) {
    $port = new-Object System.IO.Ports.SerialPort COM1,9600,None,8,one
    $port.open()
    $port.WriteLine($message)
    $port.Close()
}

Write-SerialPort ("STARTING GCE Startup Script")

$IsInstalled = ((Get-WindowsFeature -Name Web-Server).installed)
if ($isinstalled -eq $false){
    Install-WindowsFeature Web-Server -IncludeManagementTools -IncludeAllSubFeature -Confirm:$false
    Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45
    Write-SerialPort ("Installation Complete")
}
else{
    Write-SerialPort ("IIS Server (WebServer) is already installed")
}

Write-SerialPort ("FINISHING GCE Startup Script")

推荐答案

从我可以进行的测试来看,您似乎在

From what I could test on my end, it looks like you're adding the Cloud Storage path for the PowerShell script in the windows-startup-script-ps1 metadata key, which is meant for local startup scripts that have previously been added to the VM's image, instead of the windows-startup-script-url key that supports GCS objects:

$ gcloud计算实例创建your-windows-instance --scopes storage-ro --metadata windows-startup-script- url = gs://mybucket/metadata.ps1

$ gcloud compute instances create your-windows-instance --scopes storage-ro --metadata windows-startup-script-url=gs://mybucket/metadata.ps1

这篇关于GCE Windows启动脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆