【发布时间】:2021-01-06 09:25:11
【问题描述】:
我面临一个奇怪的问题,我的windows-startup-script-ps1 在启动时没有按照official link 运行。顾名思义,这对应于 PowerShell 脚本。进一步查看串行端口日志后,我发现错误是:
术语“gs://mybucket/metadata.ps1”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,或者如果包含路径,请验证 请确认路径正确,然后重试。
我尝试为其提供 Cloud Storage API 对象路径,但仍然出现此错误。我的 Compute Engine 虚拟机具有只读云存储访问权限,我通过在我的 Compute Engine 虚拟机中运行 gsutil 来验证它。谁能解释一下这个问题?
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")
【问题讨论】:
-
你想在使用之前检查
gs://mybucket/metadata.ps1的访问和存在。 -
是的,我可以访问此计算 VM 内的存储桶。 gsutil ls 给我结果
-
是的,所以如果我在这个 VM 中执行 gsutil ls,我可以看到 mt 存储桶的内容。我应该分享什么代码,powershell 脚本?
-
我在问题中添加了 PS 脚本
标签: google-cloud-platform google-cloud-storage google-compute-engine