#配置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

#带有参数的DSCConfiguration

Configuration MyParametrizedConfiguration
{
# Parameters are optional
param ($MyTargetNodeName, $MyGroupName) Node $MyTargetNodeName
{
# Group is a built-in resource that you can use to manage local Windows groups
# This example ensures the existence of a group with the name specified by $MyGroupName
Group MyGroupExample
{
Ensure = "Present" # Checks whether a group by this GroupName already exists and creates it if it does not
Name = $MyGroupName
}
}
}
MyParametrizedConfiguration -MyTargetNodeName "Server001" -MyGroupName "TestGroup" 

Start-DSCConfiguration MyParametrizedConfiguration -wait

PowerShell内置DSC资源:http://technet.microsoft.com/en-us/library/dn282120.aspx

=======================================================================

configuration dsc_service
{
param ($servicename)
Log dsc_service_log
{Message = "It's a message from DSC:Servicename = $servicename"}

Service ServiceExample
{
Name = $servicename
StartupType = "Automatic"
State = "Running"
}
}

#查看已定义的ConfigurationType
get-command -CommandType Configuration

get-command -CommandType Configuration|Remove-Item (删除)

启用配置:

dsc_service -servicename Spooler(如果没有定义参数的话,则不需要加参数选项),默认配置文件保存到当前目录下,生成后可以将其移走

将配置推送到目标计算机:

Start-Dscconfiguration -Computername localhost .\dsc_service (由于未在配置中定义目标节点,所以此处使用computername参数作为目标计算机)

-Wait:等待配置完成

-Verbose:输出详细信息流到窗口

查看当前计算机已有的DSC配置(只有start-dscconfiguration之后才能get-dscconfiguration,此处为Message说明)

Get-DscConfiguration

查找DSC可用资源及其相应参数:

Get-DscResource

(Get-DscResource -Name File).properties|ft -Wrap

The Restore-DscConfiguration cmdlet restores the previous configuration for the node, if a previous configuration exists. Specify computers by using Common Information Model (CIM) sessions. If you do not specify a target computer, the cmdlet restores the configuration of the local computer.

$Session = New-CimSession –ComputerName "Server01" –Credential ACCOUNTS\PattiFuller
Restore-DscConfiguration -CimSession $Session

DSC配置的更多相关文章

  1. 4.PowerShell DSC核心概念之配置

    什么是配置 DSC 配置是定义某一特殊类型函数的 PowerShell 脚本. 配置的语法 Configuration MyDscConfiguration { #配置块 Import-DscReso ...

  2. 5.PowerShell DSC核心概念之资源

    什么是资源? 资源为 DSC 配置提供构建基块. 资源公开可配置的属性,并包含本地配置管理器 (LCM) 调用以"使其如此"的 PowerShell 脚本函数. 系统内置资源 可在 ...

  3. 3.PowerShell DSC核心概念

    PowerShell DSC有三个核心概念 配置 配置是声明性的PowerShell 脚本,用于定义和配置资源实例. DSC 配置是幂等的. 资源 资源是 DSC 的"实现器"部分 ...

  4. 1.PowerShell DSC概述

    什么是PowerShell DSC DSC 是一个声明性平台,用于配置.部署和管理系统. PowerShell PowerShell 是构建于 .NET 上基于任务的命令行 shell 和脚本语言. ...

  5. 在 Azure 中将基础结构自动化工具与虚拟机配合使用

    若要以一致的方式大规模创建和管理 Azure 虚拟机 (VM),通常需要某种形式的自动化. 可以通过许多工具和解决方案来自动完成整个 Azure 基础结构部署和管理生命周期. 本文介绍了一些可以在 A ...

  6. GOLDENGATE 配置文档,各类参数--转发

    1       GoldenGate简要说明 GoldenGate现在是业内成熟的数据容灾与复制产品,经过多年的发展与完善,现在已经成为业内事实上的标准之一. GoldenGate软件是一种基于日志的 ...

  7. 配置ogg异构mysql-oracle 单向同步

    从mysql到oracle和oracle到mysql差不多.大致步骤如下: 环境是:192.168.0.165 (Mysql ) —> 192.168.0.164 ( Oracle )想将mys ...

  8. 配置ogg异构oracle-mysql(3)目的端配置

    目的端配置大致分为如下三个步骤:配置mgr,配置checkpoint table,配置应用进程 在目的端先创建一张表,记得带主键: mysql> create database hr;Query ...

  9. 配置ogg异构oracle-mysql(2)源端配置

    源端配置大致分为如下三个步骤:配置mgr,配置抽取进程,配置投递进程 在源端先创建一张表,记得带主键: SQL> create table ah4(id int ,name varchar(10 ...

随机推荐

  1. 我的JAVA基础学习史1

    又开始学习了..很是兴奋呢~~~~ 本来是想学安卓的,但是安卓的视频课程中,第一阶段是环境,第二阶段是JAVA基础(讲课的这个老师真是在念课本,但是实在没有办法,没找到更好.更完整的资料了). 虽然以 ...

  2. windows下的go语言的环境搭建和初探

    闲话不说,直入主题. 1.准备工具 a.windows下的Go语言开发安装包 官方下载地址:https://code.google.com/p/go/downloads/list b.Go语言中文官网 ...

  3. Hadoop伪分布模式配置部署

    .实验环境说明 注意:本实验需要按照上一节单机模式部署后继续进行操作 1. 环境登录 无需密码自动登录,系统用户名 shiyanlou,密码 shiyanlou 2. 环境介绍 本实验环境采用带桌面的 ...

  4. 函数 buf_chunk_init

    http://www.tuicool.com/articles/3QbYfm http://www.360doc.com/content/13/1216/17/12904276_337644353.s ...

  5. bzoj1150: [CTSC2007]数据备份Backup

    题目大意: 在n个点中,选出k对相邻的互不相同的点,使k段距离的总和最小. 贪心,双向链表. 首先,点之间的距离是动态的,所以要用堆来维护.   每次都选择最近的点.但因为其他情况,可能最终不会选择这 ...

  6. 【Struts】strust.xml中<result type="">所有类型详解

    在默认时,<result>标签的type属性值是“dispatcher”(实际上就是转发,forward).开发人员可以根据自己的需要指定不同的类型,如redirect.stream等.如 ...

  7. 如何卸载eclipse中的ADT

    卸载ADT的方法,方法如下: 1.选择 Help > Install New Software: 2.在"Details" 面板中, 点击"What is alre ...

  8. java中的final关键字

    谈到final关键字,想必很多人都不陌生,在使用匿名内部类的时候可能会经常用到final关键字.另外,Java中的String类就是一个final类,那么今天我们就来了解final这个关键字的用法.下 ...

  9. js 数组常用方法说明

    //push 向数组最后添加一项 var arr = ['one', 'two', 'three']; arr.push("four"); console.log(arr);//[ ...

  10. Python几个算法实现

    1.平衡点问题: 比如int[] numbers = {1,3,5,7,8,25,4,20}; 25前面的总和为24,25后面的总和也是24,25这个点就是平衡点:假如一个数组中的元素,其前面的部分等 ...