mkht / dscr_application Goto Github PK
View Code? Open in Web Editor NEWPowerShell DSC Resource to Install / Uninstall Windows Desktop Applications.
License: MIT License
PowerShell DSC Resource to Install / Uninstall Windows Desktop Applications.
License: MIT License
Hi,
Amazing DSC module, I really appreciate the hard work and the thoroughness you've put into it! 👍
I'm trying to build automated dev/test/staging/prod environments using DSC.
We need to control the .NET hosting bundle version (.NET, .NET Core, ASP.NET + Core) versions in the environments, so we don't run on version i.e. 6.0.8 in Dev, 6.0.11 in Test and 6.0.13 in Staging/Prod.
So I check and uninstall any "wrong" versions in a PreAction script - works perfect!
But the installed version consists of 4 versions fields, Major, Minor, Build and Revision.
We would like developers to specific i.e. "6.0.8" in the variable and leave the rest of script to handle rest - which works fine.
This would look like:
But the actual installed version looks like this:
So when the DSC tries to compare versions, they don't match, because of the Revision field.
And we have to match on the Major, Minor and Build versions only.
Any idea how I can do this with the Version and UseSemVer checks?
cApplication dotnetHostingBundle {
Name = "Microsoft .NET [\.\d]+ - Windows Server Hosting"
Fuzzy = $true
UseSemVer = $true
PreAction = $VersionCheckScriptBlock
Version = "=$InputVer"
InstallerPath = $dotNetURL
Arguments = '/install /passive /norestart'
Credential = $domainAdminCredentialNetBios
ReturnCode = 0,3010
NoRestart = $true
}
As this way it comes back with:
[[cApplication]dotnetHostingBundle] The application "Microsoft .NET [.\d]+ - Windows Server Hosting" is installed. but NOT match your desired version. (Desired version: "6.0.8", Installed version: "6.0.8.22363")
And I can't use ">=$InputVer" and that would also make the check think 6.0.9+ is OK.
.Revision is updated during normal patching and this version change is accepted by the test department.
So I need to do an exact version match, but only on Major.Minor.Build.
In the PreAction script I do it like this:
If ([Version]::new($RequestedVer.Major,$RequestedVer.Minor,$RequestedVer.Build) -ne [Version]::new($InstalledVer.Major,$InstalledVer.Minor,$InstalledVer.Build)) {
Any idea how I can achieve this, without having to
HKLMにインストールされたソフトが1つしかない環境でTest-TargetResource実行時に以下の例外が発生する
[System.Management.Automation.PSObject] に 'op_Addition' という名前のメソッドが含まれないため、メソッドの呼び出しに失敗しました。
発生場所 行:7 文字:9
+ $local:InstalledPrograms += Get-ChildItem $UninstallRegUser | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (op_Addition:String) []、RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
任意のスクリプトブロックをTestスクリプトとして使えるようにする
DSCR_Application/DSCResources/cApplication/cApplication.psm1
Lines 679 to 682 in 18e2d63
I have an application which is named like MyApp [domain.com-5EF64F32]
. This is an application from a relatively popular vendor and I have no influence over the naming. I believe it updates the CRC32 every update.
Get-ItemProperty : Cannot retrieve the dynamic parameters for the cmdlet. The specified wildcard character pattern is not valid: MyApp [domain.com-5EF64F32]
At line:4 char:83
+ ... stallRegMachine | ForEach-Object { Get-ItemProperty $_.PSPath } | Whe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Changing the above instances to a literalpath resolves this issue:
Get-ItemProperty -LiteralPath $_.PSPath
There should be 2 more parameters added. PostActionArgumentList & PreActionArgumentList.
These parameters should be forwarded to Invoke-ScriptBlock function:
https://github.com/mkht/DSCR_Application/blob/master/DSCResources/cApplication/cApplication.psm1#L717
Might have to change the type from
[string[]]$Arguments
to
Object[]$Arguments
cApplication AcrobatReader_Installed
{
Ensure = 'Present'
Name = '^Adobe Acrobat Reader DC'
Fuzzy = $true
InstallerPath = 'ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1900820071/AcroRdrDC1900820071_ja_JP.exe'
Arguments = '/sAll /rps /msi DISABLEDESKTOPSHORTCUT=1'
NoRestart = $true
}
詳細: [DESKTOP-17N8DUH]: [[cApplication]AcrobatReader_Installed] The application "^Adobe
Acrobat Reader DC" is not installed.
詳細: [DESKTOP-17N8DUH]: [[cApplication]AcrobatReader_Installed] Mismatch desired state &
current state. Return "False"
詳細: [DESKTOP-17N8DUH]: LCM: [ 終了 テスト ] [[cApplication]AcrobatReader_Installed] (0.0470 秒)。
詳細: [DESKTOP-17N8DUH]: LCM: [ 開始 設定 ] [[cApplication]AcrobatReader_Installed]
詳細: [DESKTOP-17N8DUH]: [[cApplication]AcrobatReader_Installed] Ensure = "Present". Try to
install an application.
詳細: [DESKTOP-17N8DUH]: [[cApplication]AcrobatReader_Installed] Use Installer
("ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1900820071/AcroRdrDC1900820071_ja_JP.exe") for Install. (if the
path of installer as http/https/ftp. will download it)
Microsoft.PowerShell.Commands.WriteErrorException: System.Management.Automation.RuntimeException: このオブジェクトにプ
ロパティ 'AllowAutoRedirect' が見つかりません。プロパティが存在し、設定可能であることを確認してください。
場所 System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception
exception)
場所 System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
場所 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
場所 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
場所 System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
場所 System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
場所 System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToPro
cess)
場所 System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
場所 System.Management.Automation.CommandProcessorBase.Complete()
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-TargetResource
+ PSComputerName : localhost
詳細: [DESKTOP-17N8DUH]: LCM: [ 終了 設定 ] [[cApplication]AcrobatReader_Installed] (0.0930 秒)。
例えば、
InstallerPath = 'http://hoge.local/install.exe'
のようにファイルへの直接リンクであれば問題ないが、
InstallerPath = 'https://download.mozilla.org/?product=firefox-54.0.1&os=win&lang=ja'
のようなリダイレクトされるタイプのURLを指定するとダウンロードに失敗してエラーになる
詳細: [DESKTOP-MHVP83I]: [[cApplication]Install::[cFirefox]FireFox_Install] Use Installer ("https://download.mozilla.org/?product=firefox-54.0.1&os=win&lang=ja") for Install. (if the path of installer as http/https/ftp. will download it)
詳細: [DESKTOP-MHVP83I]: [[cApplication]Install::[cFirefox]FireFox_Install] Download file from 'https://download.mozilla.org/?product=firefox-54.0.1&os=win&lang=ja' to 'C:\Windows\TEMP\?product=firefox-54.0.1&os=win&lang=ja'
指定されたファイルが見つかりません。
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-TargetResource
+ PSComputerName : localhost
引数が空の文字列であるため、パラメーター 'Path' にバインドできません。
+ CategoryInfo : InvalidData: (:) []、CimException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
+ PSComputerName : localhost
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.