0

我被分配了一个脚本来创建 POWERSHELL DSC 脚本 练习是:您的任务是设计和实现一个通用 PowerShell DSC 脚本,用于将任何可执行文件作为 Windows 服务部署和运行。我开始编写配置文件但由于某种原因脚本运行不佳。

Configuration helloworld
{
    Node localhost
    {
        script SayHello
        {
            GetScript = { @{} }
            TestScript = { $false }
            SetScript = { wite-verbose "Hello World" } 
        }
    }
}

Helloworld

Start-DscConfiguration -Wait -Verbose -Path .\HelloWord
4

1 回答 1

0

错误信息

    Start-DscConfiguration -Wait -Verbose -Path .\HelloWord
WARNING: The configuration 'helloworld' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource –ModuleName 'PSD
esiredStateConfiguration' to your configuration to avoid this message.


    Directory: C:\Users\admin\helloworld


Mode                LastWriteTime         Length Name                                                                                                                    
----                -------------         ------ ----                                                                                                                    
-a----       22/02/2020     08:19           1952 localhost.mof                                                                                                           
Start-DscConfiguration : .\HelloWord is not a valid directory.
At line:16 char:1
+ Start-DscConfiguration -Wait -Verbose -Path .\HelloWord
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Start-DscConfiguration], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.StartDscConfigurationCommand
于 2020-02-22T06:22:55.863 回答