标签: dsc

PowerShell DSC - 如何将配置参数传递给ScriptResources?

我在尝试使用PowerShell所需状态配置脚本来配置内部应用程序时遇到了很多麻烦.问题的根源是我似乎无法将配置数据传递给ScriptResource(至少不是我尝试这样做的方式).

我的脚本应该为我们的内部应用程序创建一个配置文件夹,然后将一些设置写入文件:

configuration MyApp {
    param (
        [string[]] $ComputerName = $env:ComputerName
    )
    node $ComputerName {

        File ConfigurationFolder {
            Type = "Directory"
            DestinationPath = $Node.ConfigFolder
            Ensure = "Present"
        }

        Script ConfigurationFile {
            SetScript = {
                write-verbose "running ConfigurationFile.SetScript";
                write-verbose "folder = $($Node.ConfigFolder)";
                write-verbose "filename = $($Node.ConfigFile)";
                [System.IO.File]::WriteAllText($Node.ConfigFile, "enabled=" + $Node.Enabled);
            }
            TestScript = {
                write-verbose "running ConfigurationFile.TestScript";
                write-verbose "folder = $($Node.ConfigFolder)";
                write-verbose "filename = $($Node.ConfigFile)";
                return (Test-Path $Node.ConfigFile);
            }
            GetScript = { @{Configured = (Test-Path $Node.ConfigFile)} }         
            DependsOn = "[File]ConfigurationFolder"
        } …
Run Code Online (Sandbox Code Playgroud)

powershell dsc

25
推荐指数
4
解决办法
2万
查看次数

在Windows 10中没有通过OneGet/PackageManagement安装Chocolaty软件包?

我正在尝试使用带有chocolaty的oneget,它似乎根本不起作用.该软件包说它已安装,没有任何警告或通知.它将软件包安装在choco目录中,但不运行安装脚本,因此实际上并未安装应用程序.请注意,这是Windows 10(Powershell 5).

Get-PackageProvider –Name Chocolatey -ForceBootstrap
Set-PackageSource -Name chocolatey -Trusted 
Install-package filezilla -Verbose -Force -ProviderName chocolatey
Run Code Online (Sandbox Code Playgroud)

产量

powershell来自命令

windows目录

powershell nuget chocolatey dsc windows-10

14
推荐指数
1
解决办法
3022
查看次数

如何解决"无法调用SendConfigurationApply方法".何时执行Start-DscConfiguration?

另一种不那么明确地表达问题的方法:在目标机器上"重置"DSC过程的正确方法是什么?

我已经创建了一个我正在迭代的DSC配置,我正在添加新的Package配置,这是我错了.我确定通过忘记在Package块中向MSI安装程序提供/ quiet参数,我可以使Start-DscConfiguration cmdlet"挂起".

在此"挂起"开始时,我停止本地计算机上的DSC配置操作并尝试更正配置问题(通过在我的示例中添加/ quiet参数),然后重新启动DSC操作.现在我在操作期间看到了远程机器的以下内容:

Cannot invoke the SendConfigurationApply method. The PerformRequiredConfigurationChecks method is in progress and must return before SendConfigurationApply can be invoked.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : REMOTEMACHINE20
Run Code Online (Sandbox Code Playgroud)

不幸的是,访问正在配置的远程PC我看到类似的错误消息,并重新启动PC似乎并没有纠正错误.

我在网上看过一些关于这个问题的帖子,到目前为止我发现的三个帖子提示:

  1. "等一会儿,它会自行解决",这对我没用(也许我很不耐烦......).不是一个成熟的长期解决方案.
  2. "删除所有本地.mof文件,然后重试",这对我来说也没用.
  3. 使用名称中的"wmi"停止所有进程,然后在目标计算机上重新启动winrm服务.这让我畅通无阻,但我希望有更好的方法来做到这一点.(如果我在接下来的几天里没有听到更好的方法,我会自己用这个程序来回答这个问题,以获得所需的结果).

powershell powershell-4.0 dsc

13
推荐指数
2
解决办法
5780
查看次数

作为部署的一部分,您如何自动分发所需状态配置自定义资源?

我正在努力利用微软的DSC Resource Kit(特别是XWebAdministration,至少对于初学者而言).我对DSC比较熟悉,所以不用担心脚本的实际功能......它做了它应该做的事情,或者至少我很确定它确实如此.

问题是当我从我的业务流程框执行脚本时,我所定位的服务器会返回此错误:

The PowerShell provider xWebAdministration does not exist at the PowerShell module 
path nor is it registered as a WMI provider.
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager 
   :String) [], CimException
    + FullyQualifiedErrorId : ModuleNameNotFound
    + PSComputerName        : [redacted]
Run Code Online (Sandbox Code Playgroud)

发生这种情况的原因显而易见:我没有xWebAdministration在这些机器上安装模块.问题是:作为部署的一部分,自动分发自定义资源的正确方法是什么?在几十个或几百个盒子上手动安装自定义资源是很麻烦的,所以必须有一种方法,我在任何地方都看不到任何关于这个主题的文档.

powershell dsc

9
推荐指数
1
解决办法
2391
查看次数

使用Powershell所需配置状态的应用程序池高级设置

如何使用Powershell修改新的或现有的应用程序池中的各种设置?我对某些"高级"设置很感兴趣,例如启用32位应用程序,管理流水线模式,流程模型标识等.有关如何执行此操作的任何想法?我尝试使用xWebAdministration模块,但似乎有非常基本的设置.在此先感谢您的帮助!

iis powershell application-pool dsc

9
推荐指数
1
解决办法
1万
查看次数

Azure DSC扩展:什么是"模块限定的配置名称"

在Azure门户(ARM)中为VM设置Azure DSC扩展时,我们会找到以下表单.突出显示的文本字段中有什么内容,它要求我指定哪个模块?xPSDesiredStateConfiguration模块?这不起作用,我想不出任何其他.

该条目必须与正则表达式匹配: "^[^\\]+\\[^\\]+$"

将鼠标悬停在信息按钮上会显示:"模块定义配置功能,功能以'模块\功能'为格式".

门户DSC扩展对话框

azure dsc azure-resource-manager azureportal

8
推荐指数
1
解决办法
811
查看次数

使用Powershell DSC安装可执行文件

我正在尝试使用PowerShell DSC安装Visual Studio 2013,但我遇到了一些问题,并希望你们能为我清理它.DSC是否能够重新启动节点然后恢复VS的安装?有谁知道这个错误意味着什么?"已安装vs_ultimate.exe,但指定的ProductId和/或名称与包详细信息不匹配"

有没有人有任何更具体的例子尝试使用此方法安装.exe?

有人如何找出ProductID?

有谁知道ReturnCode的确切语法?

任何帮助都会很棒!

powershell powershell-4.0 dsc

7
推荐指数
2
解决办法
4539
查看次数

使用Powershell DSC Package资源安装exe获取返回码1619

我正在尝试使用Powershell DSC的Package资源来安装exe ... Perforce的P4V是具体的.这是我的代码:

Configuration PerforceMachine
{
    Node "SERVERNAME"
    {
        Package P4V
        {
            Ensure = "Present"
            Name = "Perforce Visual Components"
            Path = "\\nas\share\p4vinst64.exe"
            ProductId = ''
            Arguments = "/S /V/qn" # args for silent mode
            LogPath = "$env:ProgramData\p4v_install.log"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

运行时,这是Powershell给我的错误:

PowerShell provider MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1619 was not expected. Configuration is likely not
correct
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : …
Run Code Online (Sandbox Code Playgroud)

powershell windows-installer p4v dsc

7
推荐指数
1
解决办法
1万
查看次数

删除PowerShell DSC配置

应用后,是否可以从计算机中删除DSC配置?

例如,我有一个configuration块如下:

configuration SevenZip {
    Script Install7Zip {
        GetScript = {
            $7ZipFolder = '{0}\7-Zip' -f $env:ProgramFiles;
            $Result = @{
                Result = '';
                }
            if (Test-Path -Path $7ZipFolder) {
                $Result.Result = 'Present';
            }
            else {
                $Result.Result = 'Nonpresent';
            }
            Write-Verbose -Message $Result.Result;
            $Result;
        }
        SetScript = {
            $7ZipUri = 'http://colocrossing.dl.sourceforge.net/project/sevenzip/7-Zip/9.20/7z920-x64.msi';
            $OutputFile = '{0}\7-Zip.msi' -f $env:TEMP;
            Invoke-WebRequest -Uri $7ZipUri -OutFile $OutputFile;
            Write-Verbose -Message ('Finished downloading 7-Zip MSI file to {0}.' -f $OutputFile);

            $ArgumentList = '/package "{0}" /passive /norestart /l*v "{1}\Install …
Run Code Online (Sandbox Code Playgroud)

powershell dsc

7
推荐指数
3
解决办法
1万
查看次数

Azure RM模板.如何使用VS自动上传资源,而不是从GitHub中获取资产

我希望能够部署一个复杂的ARM模板,该模板利用我的本地Visual Studio中的DSC扩展和嵌套模板.该示例设置为从GitHub下载资产:https: //github.com/Azure/azure-quickstart-templates/tree/master/active-directory-new-domain-ha-2-dc 我需要做哪些更改我可以将资产绑定到我的本地Visual Studio项目并使用它们而不是从GitHub下载它们?以下是负责下载的模板的精简版:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    ...
    "adPDCVMName": {
      "type": "string",
      "metadata": {
        "description": "The computer name of the PDC"
      },
      "defaultValue": "adPDC"
    },
    "assetLocation": {
      "type": "string",
      "metadata": {
        "description": "The location of resources such as templates and DSC modules that the script is dependent"
      },
      "defaultValue": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/active-directory-new-domain-ha-2-dc"
    }
    ...
  },
  "variables": {
    ...
    "adPDCModulesURL": "[concat(parameters('assetLocation'),'/DSC/CreateADPDC.ps1.zip')]",
    "adPDCConfigurationFunction": "CreateADPDC.ps1\\CreateADPDC",
    ...
  },
  "resources": [
    ...
    {
      "name": "[parameters('adPDCVMName')]",
      "type": "Microsoft.Compute/virtualMachines",
      ...
      "resources": [ …
Run Code Online (Sandbox Code Playgroud)

json azure dsc azure-resource-manager

6
推荐指数
1
解决办法
264
查看次数