#配置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. C#获取本地打印机列表,并将指定打印机设置为默认打印机

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  2. 【HDOJ】4601 Letter Tree

    挺有意思的一道题,思路肯定是将图转化为Trie树,这样可以求得字典序.然后,按照trie的层次求解.一直wa的原因在于将树转化为线性数据结构时要从原树遍历,从trie遍历就会wa.不同结点可能映射为t ...

  3. POI2001 Gold mine(二叉排序树 黑书经典)

    采矿(KOP) 金矿的老师傅年底要退休了.经理为了奖赏他的尽职尽责的工作,决定送他一块长方形地.长度为S,宽度为W.老师傅可以自己选择这块地.显然其中包含的采金点越多越好.你的任务就是计算最多能得到多 ...

  4. Jquery动画第二部分

    效果图:     →→→→→→ <%@ Page Language="C#" AutoEventWireup="true" CodeFile=" ...

  5. BZOJ2542: [Ctsc2001]终极情报网

    题解: 乘积最小只需要取对数.然后反向边就变成1/c,而不是-c了. 精度问题搞得我已经我想说什么了... 贴一份网上的pascal 代码: type ss=record x,y,c,r,next:l ...

  6. android 三目运算符 运用错误

    /************************************************************************** * android 三目运算符 运用错误 * 说 ...

  7. 【C++】【斐波那契】求第几个斐波那契数字。

    首先在头文件 whichfibonaccinumber.h 中写了一个使用加法的解法.没有验证输入数字是否小于0. #ifndef WHICHFIBONACCINUMBER_H_ #define WH ...

  8. c#里BindingFlags 筛选标志

    下列 BindingFlags 筛选标志可用于定义包含在搜索中的成员: 为了获取返回值,必须指定 BindingFlags.Instance 或 BindingFlags.Static. 指定 Bin ...

  9. NetCat简介与使用方法

    精品学习网考试频道小编应广大考生的需要,特为参加考试的考生策划了“NetCat简介与使用方法”专题等有关资料,供考生参考! 在入侵中它是最经典的工具之一 ,NetCat被所有的网络安全爱好者和研究者称 ...

  10. UVA 11624 Fire! BFS搜索

    题意:就是问你能不能在火烧到你之前,走出一个矩形区域,如果有,求出最短的时间 分析:两遍BFS,然后比较边界 #include<cstdio> #include<algorithm& ...