OneIdentity / safeguard-ps

One Identity Safeguard PowerShell scripting resources
Apache License 2.0
22 stars 27 forks source link

New-SafeguardAccessRequest cmdlet ignores -AccessRequestType parameter (works for 6.x cmdlets) #452

Closed holger-weihe closed 1 year ago

holger-weihe commented 1 year ago

After update of the safeguard-ps package from version 6 to 7 the cmdlet New-SafeguardAccessRequest does not work anymore. It looks like the cmdlet ignores the -AccessRequestType parameter so if you have an access request policy in Safeguard which gives access for the requested acccount on that asset in example to a password and a session the cmdlet will find more then one object which will cause an error because the cmdlets expects to find one object only.

almauser

If you run the script attached with the account configured as described you will get something like:

PS C:\.....\WindowsPowerShell\Scripts> .\almauser.ps1
Found 3 requestable accounts matching 'almauser'
At C:\Program Files\WindowsPowerShell\Modules\safeguard-ps\7.1.83373\requests.psm1:104 char:13
+             throw "Found $($local:Accounts.Count) requestable account ...
    + CategoryInfo          : OperationStopped: (Found 3 request...hing 'almauser':String) [], RuntimeException
    + FullyQualifiedErrorId : Found 3 requestable accounts matching 'almauser'

almauser.ps1.txt

miroberts commented 1 year ago

There was a change in the Powershell module to use the v4 API and this error was introduced. We will fix this.

miroberts commented 1 year ago

Will you please try this fix. https://github.com/OneIdentity/safeguard-ps/pull/454

petrsnd commented 1 year ago

Fixed build may be found here: https://www.powershellgallery.com/packages/safeguard-ps/7.2.88225-pre

petrsnd commented 1 year ago

@holger-weihe Have you been able to verify the fix?

holger-weihe commented 1 year ago

@petrsnd Thanks for fixing. Verified and my script now works again.