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 ...
随机推荐
- 在Ubuntu 12.04安装和设置SSH服务
1.安装 Ubuntu缺省安装了openssh-client,所以在这里就不安装了,如果你的系统没有安装的话,再用apt-get安装上即可. 安装ssh-server sudo apt-get ins ...
- 蓝牙(2)用BluetoothAdapter搜索蓝牙设备示例
注意在搜索之前要先打开蓝牙设备 package com.e.search.bluetooth.device; import java.util.Set; import android.app.Acti ...
- Glimpse
给自己程序配好Glimpse. Glimpse.Mvc 有问题 遇到稍微复杂点的内套多个PartialView,内存就爆了彪1.7g,不开Glimpse一点问题都没.另外Glimpse.Nlog也有问 ...
- MySql命令的基本操作
MySQL的基本命令: 登录:mysql -h -u root -p password:*****; 例如:mysql -h127.0.0.1 -uroot -p 增加一个用户: grant all ...
- c语言之extern关键字
1.定义 extern,外面的.外来的意思.那它有什么作用呢?举个例子:假设你在大街上看到一个黑皮肤绿眼睛红头发的美女(外星人?)或者帅哥.你的第一反应就是这人不是国产的. extern就相当于他们的 ...
- 缓存你的BITMAP对象
在app中通常最占内存.占流量的元素就是图片了,图片往往又无处不在,特别是伴随着list,GridView或者ViewPager出现,这些图片随着你的滑动操作,时而出现在你的屏幕中,时而消失在屏幕之外 ...
- Struts2的struts.properties文件在哪儿啊?
老师教我们Struts2的时候叫我们建了个Struts.xml文件啊?那struts.properties呢?不需要吗? 回答1: struts.properties 是可以不要的!!!因为 stru ...
- HDU 5313 Bipartite Graph
题意:给一个二分图,问想让二分图变成完全二分图最多能加多少条边. 解法:图染色+dp+bitset优化.设最终的完全二分图两部分点集为A和B,A中点个数为x,B中点个数为y,边数则为x × y,答案即 ...
- 犯罪构成三层次记忆口诀 zt
犯罪构成三层次记忆口诀 2012-02-17 来源:为你辩护网 浏览次数:232 0 众所周知,犯罪构成“四要件”和犯罪构成“三层次”(“三阶层”)都是分析具体刑事案件的辅助性工具.犯罪构成四要件是指 ...
- Linux批量修改指定目录下的文件或文件夹权限
在Puppet下很头大,尤其是文件拷贝,使用file的mode会导致文件或文件夹都一个权限. 暂时使用命令代替: 最近忙着明年的N多计划,待有空后继续研究.