SCRT-HQ/PSGSuite

Update pipeline compatibility and fix output object types

Closed this issue · 1 comments

PSGSuite already supports pipeline, but parts of it can be somewhat non-intuitive to use (i.e. piping Get-GSUser -Filter "IsAdmin -eq '$false'" | Update-GSUser -Suspended:$false would not actually unsuspend all the admins, as it would attempt to pass the entire User object and not just the PrimaryEmail)

Also, this will simultaneously remove the Select-Object calls after each object, instead using Add-Member to not break the object type.

All in all, here's what's planned:

  1. Replace Select-Object with Add-Member:
# From this...
$userObj | 
	Select-Object @{N = "User";E = {$User}},*

# To this...
$userObj | 
	Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
  1. Override the built-in ToString() method on the object:
$userObj | 
	Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru  | 
	Add-Member -MemberType ScriptMethod -Name ToString -Value {$this.PrimaryEmail} -PassThru -Force

updates deployed in v2.6.0