kubasiatkowski / SCCMChoco

GNU Lesser General Public License v3.0
44 stars 14 forks source link

Initial comments #1

Closed teknowledgist closed 6 years ago

teknowledgist commented 7 years ago

@kubasiatkowski I like it! Certainly a nice start.

Two things to think about:
  1. I've been manually creating my chocolatey deployments and I use a detection method (below) to both check for successful install and to keep packages up-to-date. It would be a nice option for your module. I'd probably make it an option in case you want to mix fixed- and updating-version installs.
# This will compare the latest available package version in the set
#   repositories with the current, Chocolatey-installed version.  
#   If the available version is "newer enough" (versioning as
#   Major.Minor.Build.Revision) than the installed version, the deployment
#   will "fail" and SCCM should command Chocolatey to install the
#   latest version.  If the user has updated the software outside
#   of Chocolatey, in most cases, Chocolatey should recognize that 
#   and only update its information, not re-install.
# Help on SCCM detection scripts:
# https://blog.kloud.com.au/2014/08/12/powershell-detection-method-for-sccm-2012-application-compliance-management/
# https://serverfault.com/questions/699705/in-what-context-do-sccm-powershell-detection-scripts-run-in
# https://blogs.technet.microsoft.com/askpfeplat/2014/12/07/how-to-correctly-check-file-versions-with-powershell/
# Accordingly, the simplest solution is:
# exit code    STDOUT     STDERR      detection state
# 0            Empty       Empty       Not installed
# 0          Not empty     Empty        Installed

$Package = '<package name here>'
$level = 'build'  # version specificity.  Choose from: major, minor, build, revision

if ($env:chocolateyinstall) {
   if ((choco list $Package -l -r -e)) {
      $row = choco outdated -r | ? {$_ -match "^$Package\|"} 

      if ($row) {
         $I,$A = $row.split('|')[1..2]

         $vTypes = 'major','minor','build','revision'
         $vIndex = [array]::indexof($vtypes,$level)

         $Installed = [version]($I.split('.')[0..$vIndex] -join '.')
         $Available = [version]($A.split('.')[0..$vIndex] -join '.')

         If ($Installed -ge $Available) {
            Write-Host "$Package fairly up-to-date!"
         }
      } else {
        Write-Host "$Package up-to-date!"
      }
   }
}

# Normal exit should have exit code = 0
  1. One thing that bothers me a bit about using Chocolatey with SCCM is that I've got thousands of computers independently downloading a large portion of the software they need from an external location. I'd like to figure out a way to bring the Chocolatey packages (or more importantly the application installers) into the local network. I think there are two parts to that:
    1. A script that would auto-download the latest packages to use to a local repository. (That could be just a hidden fileshare -- That's all I use for my non-public Chocolatey packages.) That would significantly reduce the downloads from the public repository. It would also allow packages that include the installers (rather than downloading from an external source) to reduce the external bandwidth. This should be pretty easy to do and would be a nice option for your module.
    2. A script to parse the scripts of Chocolatey packages, modify them to use a local repository and then download the application installer(s) to be called by the custom package. This would be an awesome option on your module.
      I believe this is already a feature of the licensed versions of Chocolatey, but nothing really prevents someone from doing this on their own. If I somehow figure out how to have 27 hours in a day, this is one thing I'd like to work on. My inspiration is the install script parsing that the "au" package by majkinetor does.

In any case, Chocolatey combined with SCCM is super cool! Anything that makes it easier is welcome.

kubasiatkowski commented 7 years ago

Thank you for the comment, I really appreciate your feedback.

1) Update management is in plans and it being tested. I would like to avoid automatic update by detection method because it doesn't give enough control on update process. Instead of that I prefer to run choco upgrade all and deploy it to multiple collections (testing, staging, prod, x% of computers a day, etc.). That should allow to test updates and block in case of issues.

2) That sounds interesting and I can see some benefits of keeping local repository. However, now the priority is getting basic functionality in SCCM console extension because I believe that having easy GUI will make project more accessible for bigger audience.

IvoAps commented 6 years ago

Good day,followed Your manual (I have SCCM 1702 on Server 2016) ,but getting following error while trying to add apps - WARNING: The specified file is not a valid image file. (please find screenshot attached) Any advice,please? chocolately

kubasiatkowski commented 6 years ago

Hey, do you have chocolatey.ico in the directory with scripts? It looks that the file is missing in c:\Users\Administrator.VIAMONSTRA\Desktop\sokolade\

Please let me know if missing file is a source of the problem. I don't know should I put extra checking if file exists or add troubleshooting messages to find where is the issue.

IvoAps commented 6 years ago

Thank You for fast feedback,really apreciate that! Yes,.ico file is presented,also redownloaded it,but,what is interesting,when trying to open that .ico file with IrfanView,Irfan throws up Warning message,that it is PNG file with wrong extention.
pngicowarning

After saving it as .ico file,situation didnt changed,the same warning message abou wrong image file and result in powershell..
Also renamed other random
.ico files to chocolately.ico and put them in folder with scripts,it didnt worked neither.. (do original chocolately.ico holds some specific info or its just an image? )

May be You can recheck *.ico file ,which is uploaded to github,please? Or give some suggestions,where to look for logs to get more precise picture about whats going on..

IvoAps commented 6 years ago

Additional info : Seems it is *.ico file problem....

I added -IconsDir after chochourl with path to shared folder witch contains .ico file ( in this case i tooked randomly chosen *.ico file ( originally citrix-receiver icon ) renamed it to chocolately.ico

Add-SCCMChocoApplication -chocourl "https://chocolatey.org/packages/GoogleChrome" -IconsDir '\cm01\New folder'

Everything worked as it should be by Your manual.. veiksmigs_rezultats_app

Put "working" *.ico file in directory with scripts and run script with no path to icons dir SCCMChocoApplication -chocourl "https://chocolatey.org/packages/GoogleChrome" -everything is working fine.

After that I deleted 'working' ico file and replaced with downloaded one from github .. And get the following (please see screenshot)

ar_nestradajosu_ikonu_rezultats

As far as I understand situation, 'working' *.ico file is beeing copied to App data\Local\Temp\2\ and is replacing originally one chocolately.ico in case,if original one is beeing missed or broken?

Situation is kinda tricky for making edessisions,because:

Only difference between desktop folder and shared was ,taht shared had rights for everyone. (what permissions for witch users shoud be on folder,where script files and *.ico files are located???)

On other hand- I tested renamed Citrix ico file from Desktop folder ,as I menationed before,and with no result,it started working only after I moved it to shared location..

Hope,any provided information by me will be helpful for other dudes with same situation :)

kubasiatkowski commented 6 years ago

First of all thank you for deep testing and extensive feedback. I'm trying to reproduce the issue and I'm not able to do that :( I've set up brand new testing environment (Windows 2016 + SCCM 1702) and it works fine.

I downloaded the icon as a part of full repo ZIP file (https://github.com/kubasiatkowski/SCCMChoco/archive/master.zip) and as a single file (https://github.com/kubasiatkowski/SCCMChoco/blob/master/PowerShellModule/chocolatey.ico?raw=true) and both are ok.

Maybe you have to unblock the file or it was broken by AV or proxy when downloading?

Can you try to unblock the file and open the icon in VS Code? image

First run in my lab (adding Chocolatey package): image

Adding application with default icon: image

Adding application with custom icon: image

IvoAps commented 6 years ago

Firstly,thank You for Your great job with sccm integration module and sharing it and Your knowledge with others and giving my feedback is must have and less I can do :)

Downloaded full zip file,and get following in Visual Studio Code (please find screenshots attached)

visual studio code

Matter fact-while trying to download with FF browser from https://raw.githubusercontent.com/kubasiatkowski/SCCMChoco/master/PowerShellModule/chocolatey.ico ,FF recognises it as PNG file. ff_chocolately_png

Also,when opening ico file from zip package with Notepad ++,ico file holds PNG header. png_header_choco

Must addmit,that I have no AV on or proxy connection that can corrupt file + I tried 2 ways- downloading straight to server and downlaoding to my PC (different subnet,AV (Kaspersky) on ,WIn 10 1703) and copieing to server-the same results in both cases.

At least we have a workaround what to do and make it working :)

kubasiatkowski commented 6 years ago

I updated new ico file. Could you please test it?

IvoAps commented 6 years ago

Good day,sorry for late answer-I tested new ico file,works fine (as You can see from screenshot ) ,thank You :) jauna_ikona_strada Please,explain,what was the issue??

P.S. Question out of topic- there is no difference pshell scripts are been runned from PS console in SCCM console or MS server's powershell (which is connected to SCCM',as it is in my situation ) ??

kubasiatkowski commented 6 years ago

It's also a mistery for me why the file worked for me and not for you :-/ To be honest I have no idea why one SCCM accepted PNG and another only ICO.

p.s. TL/DR: No, there is no difference. If you manage your SCCM running console at the server then you should stop doing it.

You can run the script for any computer with SCCM console which is connected to your environment. It is advised to run it from your management workstation because you should avoid logging on interactively to production servers. Furthermore, my script adds Chocolatey as a trusted repository on a computer you run the script. You have to answer yourself if you want to do it on a server.

I'm closing this comment. Please rise another issue if you have more questions.