regg00 / chocoman Goto Github PK
View Code? Open in Web Editor NEWA PowerShell wrapper for Chocolatey
License: MIT License
A PowerShell wrapper for Chocolatey
License: MIT License
Is your feature request related to a problem? Please describe.
Not a real problem. Just for convenience :)
Describe the solution you'd like
I want to pass an array of strings to Uninstall-ChocoPackage
, Install-ChocoPackage
, and other functions where this sort of feature makes sense.
It is currently not possible to do
Install-ChocoPackage -Name "firefox","vlc"
Describe alternatives you've considered
One could do this
Install-ChocoPackage -Name "firefox"
Install-ChocoPackage -Name "vlc"
Additional context
I think this makes sense for a lot of functions in order to support a wider range of use-cases.
For example:
Get-ChocoPackage
could use this to list more than one but not all packages
I'll create a PR for Uninstall-ChocoPackage
and Install-ChocoPackage
later
Is your feature request related to a problem? Please describe.
Not related to a problem per se, just an enhancement
Describe the solution you'd like
I'd like to be able to fetch details about a package. Mainly interested in tags (i.e. I might want to exclude showing admin utilities or prerequisite/runtimes by default, or only show packages applicable for a particular dept). This might not be a broadly used feature, but something I've needed several times.
Line by line, the value output is inconsistent. Some lines contain multiple data/value pairs (i.e. Publish date is output on the same line as the package title). Aside from splitting out the data to a custom PS Object, the only other consideration I think is the fact that you can fetch details from locally installed packages AND repositories. I can see one of two solutions, adding -Details parameter to Search-ChocoPackage and Get-ChocoPackage or a standalone command Get-ChocoPackageDetails and specifying a parameter to designate where to get the details from.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Attached sample output
Is your feature request related to a problem? Please describe.
Not a problem.
As stated here https://www.reddit.com/r/PowerShell/comments/15540ns/chocoman_a_powershell_wrapper_for_chocolaty/jsss27h/?utm_source=share&utm_medium=ios_app&utm_name=ioscss&utm_content=1&utm_term=1&context=3 some commands should be merged.
Is your feature request related to a problem? Please describe.
Show some kind of progress on the installation of packages.
Describe the solution you'd like
Using Write-Progress
, write the installation progress to the screen. Also, add a parameter to hide the progress. Refer to ProgressPreference
.
Describe alternatives you've considered
Just showing the choco command output would do the trick, but it's not the PowerShell way.
Describe the bug
Some actions of choco.exe
needs admin-privileges to function normally.
If you do not have them you get a warning and can choose to continue anyway. The dialog times out after 20 seconds and defaults to 'N' (Not proceed).
The output of some ChocoMan
-functions are unpredicatable, because the output cannot be parsed, so in the end you don't know if the commands were executed properly or not.
To Reproduce
Steps to reproduce the behavior:
Install-ChocoPackage -Name openscad
> Install-ChocoPackage "openscad"
Name Status Version
---- ------ -------
openscad
Expected behavior
The affected ChocoMan-Functions should give a warning that they are not started with the needed priviliges.
Additional context
The output from the commands are different. It depends on what function is used and if the package is already installed or not.
One could use choco.exe
without admin-privileges but this does not work for every package.
choco.exe
checks if the Tag admin
is present for the package and gives the above warning.
If the Tag is not present it just continues with the package installation/uninstallation/upgrade, but it depends on the package if this succeeds (maybe installing software in the users home directory)
This is also applicable for changing sources.
The above warning can not be seen when calling choco.exe
with Invoke-ChocoCmd
because it redirects all output to a variable.
You can only see it when calling choco.exe
directly.
The warning is:
Chocolatey detected you are not running from an elevated command shell
(cmd/powershell).
You may experience errors - many functions/packages
require admin rights. Only advanced users should run choco w/out an
elevated shell. When you open the command shell, you should ensure
that you do so with "Run as Administrator" selected. If you are
attempting to use Chocolatey in a non-administrator setting, you
must select a different location other than the default install
location. See
https://docs.chocolatey.org/en-us/choco/setup#non-administrative-install
for details.
For the question below, you have 20 seconds to make a selection.
Do you want to continue?([Y]es/[N]o):
Describe the solution you'd like
Chocolatey stores information on sources, API keys, and features on a chocolatey.config
file. It's an XML file that can easily be parsed.
Describe alternatives you've considered
Using choco.exe
commands output.
Additional context
https://github.com/chocolatey-community/Chocolatey/blob/8975b7356aba181d333c766c6891f991af06847a/source/public/Get-ChocolateySource.ps1#L42
Describe the bug
The Get-ChocoOutdated cmdlet will generate an error stating "Cannot validate argument on parameter 'InputObject'. The argument is null. Provide a valid value for the argument, and then try running the command again." when Chocolatey has no packages available to update. It specifically mentions the error occurring on line 44 at the (Invoke-ChocoCommand -Arguments $Arguments).RawOutput syntax.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Get-ChocoOutdated should simply return $null when no packages are outdated.
Screenshots
If applicable, add screenshots to help explain your problem.
Describe the bug
In some cases, chocolatey returns the following message [NuGet] No Authorization header detected
. That message is getting parsed as a chocolatey package and is displayed by the Get-ChocoOutdated
for example.
To Reproduce
Steps to reproduce the behavior:
Get-ChocoOutdated
Name CurrentVersion AvailableVersion Pinned
---- -------------- ---------------- ------
[NuGet] No Authorization header detected
adobereader 2023.3.20201.1 2023.3.20244 false
Expected behavior
Only a list of packages should be returned.
Desktop:
Is your feature request related to a problem? Please describe.
For testing purposes or just to see what would happen, there should be a "WhatIf"-Parameter.
Describe the solution you'd like
When I'm not sure if my command breaks something I usually test the command with an WhatIf
parameter, like:
Get-ChocoPackage | Uninstall-ChocoPackage -Verbose -WhatIf
choco.exe
supports this feature when passing one of these
--noop, --whatif, --what-if
NoOp / WhatIf - Don't actually do anything.
Describe alternatives you've considered
There is no real alternative. You could use "-Verbose" and "-Debug" but you can't call choco.exe
without specifying --noop
because this would actually execute your command.
Additional context
This can be implemented like "Force" or "AskForConfirmation"
Is your feature request related to a problem? Please describe.
Rarely comes up but today I happened to need to get list of apps that had pre-releases available and realized there wasn't support for -Pre parameter.
Describe the solution you'd like
Support for passing off -Pre parameter specifically or perhaps an "overflow" parameter that will tag a string on the end of the choco command arguments so almost any parameter can be supported
I can add -Pre or an "Additional Arguments" overflow if you'd like to tell me your preference
Is your feature request related to a problem? Please describe.
Not a problem, but a significant improvement.
The way choco outputs are parsed right now is too basic.
Describe the solution you'd like
The matching should be done more specifically using regex queries with the Select-String
command.
Describe alternatives you've considered
$CommandOutput.RawOutput -like "*$n *already installed.*"
Additional context
Given the following output:
Installing the following packages:
rufus
By installing, you accept licenses for the packages.
rufus v4.2.0 [Approved]
rufus package files install completed. Performing other installation steps.
ShimGen has successfully created a shim for rufus.exe
The install of rufus was successful.
Software installed to 'C:\ProgramData\chocolatey\lib\rufus'
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
We can extract the Name, Version and Status with those commands:
$Name = ($test | Select-String '^rufus$').matches[0].value
$Version = ($test | Select-String 'v\d.\d.\d').matches[0].value
$Installed = $test | Select-String '^ The install of rufus was successful.$' -Quiet
Is your feature request related to a problem? Please describe.
Not a problem, but the Upgrade-ChocoPackage
function could be useful sometimes especially if it supports pipeline input.
Describe the solution you'd like
Create a new function called Upgrade-ChocoPackage
that supports pipeline input.
Describe alternatives you've considered
There's already a -Upgrade
switch for Install-ChocoPackage
but it's easier to have a dedicated function.
Is your feature request related to a problem? Please describe.
Not a problem, but right now, when running Install-ChocoPackage
with the -Upgrade
switch, if the package is already up to date, then the message is not clear enough.
Describe the solution you'd like
Return a status message stating that the package is already on the latest version.
Additional context
Here's an example of an upgrade request on an already upgraded package.
PS C:\Users\regg0> install-ChocoPackage -Name winscp -Upgrade -Verbose
VERBOSE: Chocolatey is installed.
VERBOSE: Chocolatey is installed.
VERBOSE: Command to execute: choco upgrade -y winscp --source chocolatey -r --no-color
VERBOSE: Chocolatey is installed.
VERBOSE: Chocolatey is installed.
VERBOSE: Command to execute: choco list -r --no-color
Name Status Version
---- ------ -------
winscp 6.1.1
First things first: This is module is great ๐
I wanted to write my own powershell module for using choco, but I don't need that, because this is (almost, hence this issue) exactly how I want to use choco from within powershell.
Is your feature request related to a problem? Please describe.
Not really a problem. More like "using the full potential of powershell"-comfort-feature
Describe the solution you'd like
What you typically use pipelines for is something like this:
Get-Something | Filter-Something | Do-Something
What I want to use is something like that (I'll keep it simple, but you will get the point):
# I know that "Uninstall-ChocoPackage" is not implemented yet
Get-ChocoPackage | Where-Object { $_.Name -like "*vlc*" } | Uninstall-ChocoPackage
Describe alternatives you've considered
There is no alternative for the almighty powershell-pipeline :D
OK, jokes aside. There's always another way (same result as example above):
Get-ChocoPackage | Where-Object { $_.Name -like "*vlc*" } | ForEach-Object { Uninstall-ChocoPackage -Name $_ }
or
$packages = Get-ChocoPackage | Where-Object { $_.Name -like "*vlc*" }
foreach($package in $packages) {
Uninstall-ChocoPackage -Name $package
}
But i find the pipeline-approach of the cmdlets much more readable
Additional context
Please let me know if I can assist in any way by implementing this feature
Describe the bug
The Install-ChocoPackage Name parameter does support an array of package names being passed to it however it does not appear to invoke Chocolatey to install multiple packages. So if you run the following:
$PackageList = @("conemu", "pwsh", "powertoys")
Install-ChocoPackage -Name $PackageList
Only the first entry in the array (In this case ConEmu) will get installed. You can workaround the issue by using:
ForEach ($PackageName In $PackageList) { Install-ChocoPackage -Name $PackageName }
However, that invokes Chocolatey each time.
To Reproduce
Steps to reproduce the behavior:
$PackageList = @("conemu", "pwsh", "powertoys")
Install-ChocoPackage -Name $PackageList
Expected behavior
Passing a string[] value to the -Name parameter should install multiple packages defined in the array value.
Desktop (please complete the following information):
Additional context
Chocolatey does support passing a string array value to it directly as I've used this in the past on a virtual machine template to install multiple packages at the same time. The command to use is as simple as doing the following:
$PackageList = @("conemu", "powertoys", "pwsh", "notepadplusplus")
choco install $PackageList -y
Is your feature request related to a problem? Please describe.
It's cumbersome to parse choco arg in strings.
Describe the solution you'd like
Uses joins with arrays.
Additional context
https://github.com/chocolatey-community/Chocolatey/blob/8975b7356aba181d333c766c6891f991af06847a/source/public/Get-ChocolateyVersion.ps1#L27
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.