是否可以使用PowerShell创建用于安装Windows功能的通用配置文件
我目前正在尝试自动构建运行
Windows Server 2012 R2的VM.目前,挑战是自动添加角色和功能.在角色和功能向导中,有一个选项可以导出可以在PowerShell中运行的XML配置文件.
但是,在查看XML文件后,我可以看到它特定于运行它的服务器 – 它包含诸如“ComputerName”之类的字段. 如果我想运行在许多VM上安装角色和功能的脚本,该怎么办?我需要一个通用的配置文件,而不是针对特定计算机的个性化. 有没有人对此问题有任何意见?
是的,对于
Linux和Windows,您可以构建所需的状态配置文件,它们可以:
>启用或禁用服务器角色和功能 下面是一个示例配置文件,它将启用IIS,确保网站文件位于正确的文件夹中,如果没有安装或丢失任何这些内容,请根据需要安装或复制它们(请注意,$websitefilepath被认为是预定义为网站文件的来源): Configuration MyWebConfig { # A Configuration block can have zero or more Node blocks Node "Myservername" { # Next,specify one or more resource blocks # WindowsFeature is one of the built-in resources you can use in a Node block # This example ensures the Web Server (IIS) role is installed WindowsFeature MyRoleExample { Ensure = "Present" # To uninstall the role,set Ensure to "Absent" Name = "Web-Server" } # 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 # This is a path that has web files SourcePath = $WebsiteFilePath # The path where we want to ensure the web files are present DestinationPath = "C:inetpubwwwroot" # This ensures that MyRoleExample completes successfully before this block runs DependsOn = "[WindowsFeature]MyRoleExample" } } } 有关详细信息,请参阅Windows PowerShell Desired State Configuration Overview和Get Started with Windows PowerShell Desired State Configuration. 那么为什么要使用它而不仅仅是install-windowsfeature cmdlet呢?使用DSC而不是脚本的真正强大之处在于我可以定义一个位置,我可以存储要推送或拉出的配置(相对于目标机器),参见Push and Pull Configuration Modes.配置并不关心机器是否是物理的或虚拟的,但我相信至少需要2012年才能让服务器启动以提取DSC. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-7 – 为什么mkdir偶尔会拒绝访问?
- windows-server-2008 – 从Windows Server 2008连接到cups打
- windows-phone-8.1 – Windows Phone 8.1 API
- windows – HTTP无法注册URL
- 在Windows服务中托管WCF服务
- Windows上禁用SSL V3需要重启吗? – 贵宾犬利用
- windows-server-2008 – 事件36888:生成以下致命警报:10.
- 如何收集每个服务名称及其在Windows中的状态?
- windows-server-2008 – 您的系统管理员不允许使用保存的凭
- windows-server-2008 – 如何诊断重复的“启动数据库”’
- windows-installer – 使用WIX卸载现有应用程序
- active-directory – 在Windows网络中部署打印机
- window下redis的安装和创建redis启动服务
- windows-server-2008 – 使用WordPress,Microsof
- windows – 查找应用程序使用的tcp端口
- windows – 如何设计/确保Web服务器的高可用性?
- windows – 将图像作为按钮控件的背景
- .net – 如何将应用程序停靠在Windows桌面?
- 在WINDOWS中设置计划任务执行PHP文件的方法
- Windows API一日一练 54 WriteFile和ReadFile函数