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:
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.
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")
gs://mybucket/metadata.ps1before using it. - Soleil