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

Get-SafeguardMyRequest returns 1 "object" with all requests #507

Open
azirish1998 opened this issue Dec 29, 2023 · 1 comment
Open

Get-SafeguardMyRequest returns 1 "object" with all requests #507

azirish1998 opened this issue Dec 29, 2023 · 1 comment

Comments

@azirish1998
Copy link

Get-SafeguardMyRequest returns 1 "object" with all requests instead of one object for each request. Using Where-Object to filter results doesn't work... or at least not as one would expect.

Module version 7.4.126553

$ Get-SafeguardMyRequest

AccessRequestType   : Password
AccountId           : 1
AccountName         : account1
AccountDomainName   : mydomain.com
AssetId             : 1
AssetName           : mydomain
AssetNetworkAddress :
Id                  : 
IsEmergency         : False
State               : PasswordCheckedOut
TicketNumber        :

AccessRequestType   : Password
AccountId           : 2
AccountName         : account2
AccountDomainName   : mydomain.com
AssetId             : 1
AssetName           : mydomain
AssetNetworkAddress :
Id                  : 
IsEmergency         : False
State               : PasswordCheckedOut
TicketNumber        :

# Expect count here to be 2
$ Get-SafeguardMyRequest | measure

Count             : 1
Average           :
Sum               :
Maximum           :
Minimum           :
StandardDeviation :
Property          :

# Using where returns the all requests when the condition is met
$ Get-SafeguardMyRequest | where {$_.accountname -eq 'account1'}

AccessRequestType   : Password
AccountId           : 1
AccountName         : account1
AccountDomainName   : mydomain.com
AssetId             : 1
AssetName           : mydomain
AssetNetworkAddress :
Id                  : 
IsEmergency         : False
State               : PasswordCheckedOut
TicketNumber        :

AccessRequestType   : Password
AccountId           : 2
AccountName         : account2
AccountDomainName   : mydomain.com
AssetId             : 1
AssetName           : mydomain
AssetNetworkAddress :
Id                  : 
IsEmergency         : False
State               : PasswordCheckedOut
TicketNumber        :

# PS seems willing to treat it as a collection with some help?
$ Get-SafeguardMyRequest |%{ $_ | where {$_.accountname -eq 'account1'}}

AccessRequestType   : Password
AccountId           : 1
AccountName         : account1
AccountDomainName   : mydomain.com
AssetId             : 1
AssetName           : mydomain
AssetNetworkAddress :
Id                  : 
IsEmergency         : False
State               : PasswordCheckedOut
TicketNumber        :

@JeffHarkavy
Copy link
Contributor

@azirish1998 Thank you for contacting us. Apologies for the delayed response.

When invoking Get-SafeguardMyRequest if you enclose the call in parentheses or assign the output to a variable it will give you the results you expect. This likely has to do with how the output from the API call is being interpreted by PowerShell, but I'm not 100% sure of all the mechanisms involved.

PS  C:\git\safeguard-ps\src > get-safeguardmyrequest

AccessRequestType   : Password
AccountId           : 2
AccountName         : devProvdSample234
AccountDomainName   :
AssetId             : 1
AssetName           : Dev Provisioned Asset
AssetNetworkAddress : 10.9.6.58
Id                  : 2-1-3-6459-1-47c4a158beb14e6f95db35cf35cbdd20-0001
IsEmergency         : False
State               : RequestAvailable
TicketNumber        :

AccessRequestType   : Password
AccountId           : 4
AccountName         : ManualAccount
AccountDomainName   :
AssetId             : 5
AssetName           : ManualSystem
AssetNetworkAddress : 1.2.3.4
Id                  : 4-5-3-6011-1-47c4a158beb14e6f95db35cf35cbdd20-0003
IsEmergency         : False
State               : RequestAvailable
TicketNumber        :

PS  C:\git\safeguard-ps\src > (get-safeguardmyrequest) | where {$_.accountname -eq 'manualaccount'}

AccessRequestType   : Password
AccountId           : 4
AccountName         : ManualAccount
AccountDomainName   :
AssetId             : 5
AssetName           : ManualSystem
AssetNetworkAddress : 1.2.3.4
Id                  : 4-5-3-6011-1-47c4a158beb14e6f95db35cf35cbdd20-0003
IsEmergency         : False
State               : RequestAvailable
TicketNumber        :


PS  C:\git\safeguard-ps\src > $x = Get-SafeguardMyRequest
PS  C:\git\safeguard-ps\src > $x | where {$_.accountname -eq 'manualaccount'}

AccessRequestType   : Password
AccountId           : 4
AccountName         : ManualAccount
AccountDomainName   :
AssetId             : 5
AssetName           : ManualSystem
AssetNetworkAddress : 1.2.3.4
Id                  : 4-5-3-6011-1-47c4a158beb14e6f95db35cf35cbdd20-0003
IsEmergency         : False
State               : RequestAvailable
TicketNumber        :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants