我在尝试使用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) 我正在尝试使用带有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)
产量
我已经创建了一个我正在迭代的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似乎并没有纠正错误.
我在网上看过一些关于这个问题的帖子,到目前为止我发现的三个帖子提示:
我正在努力利用微软的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修改新的或现有的应用程序池中的各种设置?我对某些"高级"设置很感兴趣,例如启用32位应用程序,管理流水线模式,流程模型标识等.有关如何执行此操作的任何想法?我尝试使用xWebAdministration模块,但似乎有非常基本的设置.在此先感谢您的帮助!
在Azure门户(ARM)中为VM设置Azure DSC扩展时,我们会找到以下表单.突出显示的文本字段中有什么内容,它要求我指定哪个模块?xPSDesiredStateConfiguration模块?这不起作用,我想不出任何其他.
该条目必须与正则表达式匹配: "^[^\\]+\\[^\\]+$"
将鼠标悬停在信息按钮上会显示:"模块定义配置功能,功能以'模块\功能'为格式".
我正在尝试使用PowerShell DSC安装Visual Studio 2013,但我遇到了一些问题,并希望你们能为我清理它.DSC是否能够重新启动节点然后恢复VS的安装?有谁知道这个错误意味着什么?"已安装vs_ultimate.exe,但指定的ProductId和/或名称与包详细信息不匹配"
有没有人有任何更具体的例子尝试使用此方法安装.exe?
有人如何找出ProductID?
有谁知道ReturnCode的确切语法?
任何帮助都会很棒!
我正在尝试使用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) 应用后,是否可以从计算机中删除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) 我希望能够部署一个复杂的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) dsc ×10
powershell ×8
azure ×2
azureportal ×1
chocolatey ×1
iis ×1
json ×1
nuget ×1
p4v ×1
windows-10 ×1