Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psget.install returns error/False even though it successfully installs #59238

Open
ewhitesides opened this issue Jan 6, 2021 · 3 comments
Open
Assignees
Labels
Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Windows
Projects
Milestone

Comments

@ewhitesides
Copy link

ewhitesides commented Jan 6, 2021

Description
a state with the following generates an error, but does install the requested module successfully

pswindowsupdate:
  module.run:
    - psget.install:
      - name: pswindowsupdate

output of applying the state:

      ID: pswindowsupdate
Function: module.run
  Result: False
 Comment: 'psget.install': False
 Started: 13:22:58.168251
Duration: 13453.553 ms
 Changes:

Setup
targeting a windows server 2019 minion and also tried a 2016 minion

Steps to Reproduce the behavior
(Include debug logs if possible and relevant)

Expected behavior
current output is a false-positive error, and it would be more appropriate to report a success message.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report
3002.2 for master and minion

PASTE HERE

Additional context
Add any other context about the problem here.

@ewhitesides ewhitesides added the Bug broken, incorrect, or confusing behavior label Jan 6, 2021
@xeacott xeacott added this to To do in Windows Jan 11, 2021
@xeacott
Copy link
Contributor

xeacott commented Jan 28, 2021

Hmmm also experiencing very similar behavior. What happens when you do a psget.remove pswindowsupdate?

I think I'm getting false-positive's on the remove function too. 😅


λ salt-call --local psget.remove "pswindowsupdate"
.
.
[INFO    ] Executing command 'Powershell -NonInteractive -NoProfile "Uninstall-Module \"pswindowsupdate\" | ConvertTo-Xml -Depth 2 -As \"stream\""' in directory 'C:\Users\Joe Eacott'
[DEBUG   ] stdout: <?xml version="1.0" encoding="utf-8"?>
<Objects>
</Objects>
[DEBUG   ] stderr: PackageManagement\Uninstall-Package : No match was found for the specified search criteria and module names 'pswindowsupdate'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2194 char:21
+ ...        $null = PackageManagement\Uninstall-Package @PSBoundParameters
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package], Exception
    + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
[DEBUG   ] DSC: Get-InstalledModule | ConvertTo-Xml -Depth 2 -As "stream"
.
.

local:
    True

@xeacott xeacott added severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around and removed needs-triage labels Jan 28, 2021
@xeacott xeacott added this to the Approved milestone Jan 28, 2021
@xeacott xeacott moved this from To do to In progress in Windows Jan 28, 2021
@ewhitesides
Copy link
Author

ewhitesides commented Jan 28, 2021

for remove i think powershell will output an error when it doesn't exist directly, and in writing scripts I've used 'where-object' to get around it

#outputs error if didn't exist
Uninstall-Module PSWindowsUpdate

#avoid error with where-object
$found = get-installedmodule | where-object {$_.Name -eq 'PSWindowsUpdate'}
if ($found) {uninstall-module PSWindowsUpdate}

there's probably another option where you could null out the specific error that occurs when it's not found

@ewhitesides
Copy link
Author

ewhitesides commented Feb 11, 2021

i think the solution is that you have to provide the powershell module in exact casing as it appears. this is a bit counter-intuitive because powershell is case insensitive, but it's being passed through python first so I guess it's understandable.

updating the documentation with a note about this could be in order I think, or allowing insensitive casing would work.

[root@mymaster ~]# salt myminion psget.install PSWindowsUpdate
myminion:
True
[root@mymaster ~]# salt myminion psget.install pswindowsupdate
myminion:
False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Windows
Projects
Windows
  
In progress
Development

No branches or pull requests

3 participants