DSC配置
#配置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配置的更多相关文章
- 4.PowerShell DSC核心概念之配置
什么是配置 DSC 配置是定义某一特殊类型函数的 PowerShell 脚本. 配置的语法 Configuration MyDscConfiguration { #配置块 Import-DscReso ...
- 5.PowerShell DSC核心概念之资源
什么是资源? 资源为 DSC 配置提供构建基块. 资源公开可配置的属性,并包含本地配置管理器 (LCM) 调用以"使其如此"的 PowerShell 脚本函数. 系统内置资源 可在 ...
- 3.PowerShell DSC核心概念
PowerShell DSC有三个核心概念 配置 配置是声明性的PowerShell 脚本,用于定义和配置资源实例. DSC 配置是幂等的. 资源 资源是 DSC 的"实现器"部分 ...
- 1.PowerShell DSC概述
什么是PowerShell DSC DSC 是一个声明性平台,用于配置.部署和管理系统. PowerShell PowerShell 是构建于 .NET 上基于任务的命令行 shell 和脚本语言. ...
- 在 Azure 中将基础结构自动化工具与虚拟机配合使用
若要以一致的方式大规模创建和管理 Azure 虚拟机 (VM),通常需要某种形式的自动化. 可以通过许多工具和解决方案来自动完成整个 Azure 基础结构部署和管理生命周期. 本文介绍了一些可以在 A ...
- GOLDENGATE 配置文档,各类参数--转发
1 GoldenGate简要说明 GoldenGate现在是业内成熟的数据容灾与复制产品,经过多年的发展与完善,现在已经成为业内事实上的标准之一. GoldenGate软件是一种基于日志的 ...
- 配置ogg异构mysql-oracle 单向同步
从mysql到oracle和oracle到mysql差不多.大致步骤如下: 环境是:192.168.0.165 (Mysql ) —> 192.168.0.164 ( Oracle )想将mys ...
- 配置ogg异构oracle-mysql(3)目的端配置
目的端配置大致分为如下三个步骤:配置mgr,配置checkpoint table,配置应用进程 在目的端先创建一张表,记得带主键: mysql> create database hr;Query ...
- 配置ogg异构oracle-mysql(2)源端配置
源端配置大致分为如下三个步骤:配置mgr,配置抽取进程,配置投递进程 在源端先创建一张表,记得带主键: SQL> create table ah4(id int ,name varchar(10 ...
随机推荐
- 蓝牙(3)如何通过蓝牙传输数据及UUID详介
如何通过蓝牙传输数据 通过蓝牙传输数据与Socket类似.在网络中使用Socket和ServerSocket控制客户端和服务端的数据读写.而蓝牙通讯也由客户端和服务端Socket来完成.蓝牙客户端So ...
- Oracle DBA常用SQL
监控SQL 1.监控事例的等待: select event,sum(decode(wait_time,0,0,1)) prev, sum(decode(wait_time,0,1,0)) curr,c ...
- C++ volatile的作用
volatile的作用 2006-10-23 13:44:21 大 中 小 关键在于两个地方: 1. 编译器的优化 (请高手帮我看看下面的理解) 在本次线程内, 当读取一个变量时,为提 ...
- poj 1789 Truck History(最小生成树)
模板题 题目:http://poj.org/problem?id=1789 题意:有n个型号,每个型号有7个字母代表其型号,每个型号之间的差异是他们字符串中对应字母不同的个数d[ta,tb]代表a,b ...
- 浏览器兼容问题系列---使IE支持CSS3 Media Quary
兼容是一件很让前端攻城师头疼的事情,笔者今天在做一个Demo的时候就碰到了一个问题(大牛就不要拍砖了,谢谢!) 经常做移动互联网前端的攻城师想必对于css3 media quary已经很熟悉了,但是碰 ...
- CodeForces Round #286 Div.2
A. Mr. Kitayuta's Gift (枚举) 题意: 给一个长度不超过10的串,问能否通过插入一个字符使得新串成为回文串. 分析: 因为所给的串很多,所以可以枚举 “在哪插入” 和 “插入什 ...
- 【转】Android异步消息处理机制完全解析,带你从源码的角度彻底理解
原文网址:http://blog.csdn.net/guolin_blog/article/details/9991569 转载请注明出处:http://blog.csdn.net/guolin_bl ...
- maven的pom报plugins却是的解决方法2
Failure to transfer org.apache.maven.plugins:maven-plugins:pom:25 from https://repo.maven.apache.org ...
- ubuntu网站做图像外链
http://paste.ubuntu.org.cn
- 【原】实验室签到PHP版本
表单 <html> <body> <h1>实验室自动签到测试</h1> <h2>输入学号和登录密码(建议自己改过密码后再来录入您的数据)&l ...