#配置Remote Desktop Services服务为 自启动,并运行
Configuration Myservice
{
# A Configuration block can have zero or
more Node blocks
Node "localhost"
{
Service
ServiceExample
{
Name = "TermService"
StartupType =
"Automatic"
State = "Running"
}
}
}
Myservice
Start-DscConfiguration -wait -Verbose -Path .\Myservice
=============================================
#配置目录下文件
Configuration MyWebConfig
{
# A Configuration block can have zero or
more Node blocks
Node "localhost"
{
# File is a built-in
resource you can use to manage files and directories
# This example
ensures files from the source directory are present in the destination
directory
File MyFileExample
{
Ensure = "Present"
# You can also set Ensure to "Absent"
Type = "Directory“ # Default
is “File”
Recurse = $true
#SourcePath = $WebsiteFilePath # This
is a path that has web files
SourcePath = "C:\inetpub\wwwroot"
DestinationPath = "C:\inetpub\wwwrootdes" # The path where we want to
ensure the web files are present
#DependsOn =
"[WindowsFeature]MyRoleExample" # This ensures that MyRoleExample completes
successfully before this block runs
}
Log
AfterDirectoryCopy
{
# The message below gets written
to the Microsoft-Windows-Desired State Configuration/Analytic log
Message = "Finished running the file resource with ID DirectoryCopy"
DependsOn = "[File]MyFileExample" # This means run "DirectoryCopy" first.
}
}
}
MyWebConfig
Start-DscConfiguration -wait -Verbose -Path .\MyWebConfig
PowerShell内置DSC资源:http://technet.microsoft.com/en-us/library/dn282120.aspx
原文:http://www.cnblogs.com/dreamer-fish/p/3573963.html