blakedrumm / SCOM-Scripts-and-SQL

The scripts, tools, and queries provided here are fully compatible with System Center Operations Manager.
https://blakedrumm.com
MIT License
79 stars 35 forks source link

Get-UserRights Passthru Fails within script #7

Closed Bobberty closed 1 year ago

Bobberty commented 1 year ago

Describe the bug When changing line 467 to force passthru as a default, the system still writes the text output at the beginning of the script. Thus when treated as an object, the data turns into a small text string.

To Reproduce Steps to reproduce the behavior:

  1. Edit line 476 in the script to the following "Get-UserRights -PassThru" or as an alternative "Get-UserRights -PassThru:$True"
  2. Execute the script without parameters. Example: Get-UserRights.ps1
  3. Note that the text header still shows.
  4. See error

Expected behavior An object output that will allow easy Powershell processing.

Additional context This seems to be a flow problem. The params are assigned, header printed, default params assigned, process executed. Just guessing, but the process probably should be Params assigned, Default params assigned, header printed, process executed.

blakedrumm commented 1 year ago

@Bobberty - Thank you for submitting this issue! I have reviewed and tested. It does not seem possible to fix the line 467 to allow -PassThrough. As a workaround, you can instead change the parameter for the main script for parameter: -PassThru

Edit line 67: https://github.com/blakedrumm/SCOM-Scripts-and-SQL/blob/master/Powershell/General%20Functions/Get-UserRights.ps1#L67 replace the line with this:

[switch]$PassThru = $true