GCE Windows启动脚本因解析错误而失败

时间:2018-02-27 18:20:12

标签: google-cloud-storage google-compute-engine

我在其中一个GCS存储桶中有一个PowerShell脚本。我配置了一个GCE实例,将其用作启动脚本。此GCE实例具有服务帐户并具有必要的API访问权限。但是,当脚本开始运行时,我看到解析错误。我可以在本地运行脚本而不会出现任何问题。仅当我使用GCS存储桶时才会发生这种情况。如果我将脚本作为Github的要点,它也可以完美运行。

这是我在串行控制台日志中看到的内容。

2018/02/27 18:08:25 GCEMetadataScripts: Starting startup scripts (version 4.1.6@1). 2018/02/27 18:08:42 GCEMetadataScripts: Found windows-startup-script-url in metadata. 2018/02/27 18:10:09 windows-startup-script-url: At C:\Windows\TEMP\metadata-scripts968189735\windows-startup-script-url.ps1:2 2018/02/27 18:10:09 windows-startup-script-url: char:9 2018/02/27 18:10:09 windows-startup-script-url: + "error": { 2018/02/27 18:10:09 windows-startup-script-url: + ~ 2018/02/27 18:10:09 windows-startup-script-url: Unexpected token ':' in expression or statement. 2018/02/27 18:10:09 windows-startup-script-url: At C:\Windows\TEMP\metadata-scripts968189735\windows-startup-script-url.ps1:3 2018/02/27 18:10:09 windows-startup-script-url: char:11 2018/02/27 18:10:09 windows-startup-script-url: + "errors": [ 2018/02/27 18:10:09 windows-startup-script-url: + ~ 2018/02/27 18:10:09 windows-startup-script-url: Unexpected token ':' in expression or statement. 2018/02/27 18:10:09 windows-startup-script-url: At C:\Windows\TEMP\metadata-scripts968189735\windows-startup-script-url.ps1:5 2018/02/27 18:10:09 windows-startup-script-url: char:13 2018/02/27 18:10:09 windows-startup-script-url: + "domain": "global", 2018/02/27 18:10:09 windows-startup-script-url: + ~ 2018/02/27 18:10:09 windows-startup-script-url: Unexpected token ':' in expression or statement. 2018/02/27 18:10:09 windows-startup-script-url: At C:\Windows\TEMP\metadata-scripts968189735\windows-startup-script-url.ps1:11 2018/02/27 18:10:10 windows-startup-script-url: char:4 2018/02/27 18:10:10 windows-startup-script-url: + ], 2018/02/27 18:10:10 windows-startup-script-url: + ~ 2018/02/27 18:10:10 windows-startup-script-url: Missing argument in parameter list. 2018/02/27 18:10:10 windows-startup-script-url: + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx 2018/02/27 18:10:10 windows-startup-script-url: ception 2018/02/27 18:10:10 windows-startup-script-url: + FullyQualifiedErrorId : UnexpectedToken 2018/02/27 18:10:10 windows-startup-script-url:
2018/02/27 18:10:10 GCEMetadataScripts: windows-startup-script-url exit status 1 2018/02/27 18:10:10 GCEMetadataScripts: Finished running startup scripts.

这是启动脚本。

[DscLocalConfigurationManager()]
Configuration GCEDscMetaConfig
{

    param
    (
        [Parameter(Mandatory = $true)]
        [String]
        $RegistrationUrl,

        [Parameter(Mandatory = $True)]
        [String]
        $RegistrationKey,

        [Parameter(Mandatory = $true)]
        [String[]]
        $ConfigurationNames

    )

    Node localhost
    {

        Settings
        {
            RefreshMode = 'Pull'
        }

        ConfigurationRepositoryWeb AzureAutomationDSC
        {
            ServerUrl = $RegistrationUrl
            RegistrationKey = $RegistrationKey
            ConfigurationNames = $ConfigurationNames
        }

        ResourceRepositoryWeb AzureAutomationDSC
        {
            ServerUrl = $RegistrationUrl
            RegistrationKey = $RegistrationKey
        }

        ReportServerWeb AzureAutomationDSC
        {
            ServerUrl = $RegistrationUrl
            RegistrationKey = $RegistrationKey
        }
    }
}

$Params = @{
    RegistrationUrl    = 'https://pullserver/accounts/7471b7ce-95d2-4766-be97-221f4d33f56a'
    RegistrationKey    = 'ljey=='
    ConfigurationNames = 'webserver.localhost'
    OutputPath         = "$env:TEMP\MetaConfig"
}

GCEDscMetaConfig @Params

Set-DscLocalConfigurationManager -Path "$env:TEMP\MetaConfig" -Verbose

这只是一个DSC元配置脚本。

知道我在这里缺少什么吗?

0 个答案:

没有答案