Error with Get-TssSecretAudit : Can't convert value to type "Thycotic.PowerShell.Secrets.Audit"
Verified issue does not already exist?
Yes
What error did you receive
System.Management.Automation.RuntimeException: Cannot convert value "@{id=525028; dateRecorded=01/02/2024 18:35:46; action=VIEW; actionForDisplay=VIEW; notes=;
byUserDisplayName=Authentification User; ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=False;
username=Authentification User; application=SecretServerCloud}" to type "Thycotic.PowerShell.Secrets.Audit". Error: "Cannot convert the "@{id=525028;
dateRecorded=01/02/2024 18:35:46; action=VIEW; actionForDisplay=VIEW; notes=; byUserDisplayName=Authentification User; ticketNumber=; recordingStatus=-1;
recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=False; username=Authentification User; application=SecretServerCloud}"
value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Secrets.Audit"."
---> System.Management.Automation.PSInvalidCastException: Cannot convert value "@{id=525028; dateRecorded=01/02/2024 18:35:46; action=VIEW; actionForDisplay=VIEW; notes=;
byUserDisplayName=Authentification User; ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=False;
username=Authentification User; application=SecretServerCloud}" to type "Thycotic.PowerShell.Secrets.Audit". Error: "Cannot convert the "@{id=525028;
dateRecorded=01/02/2024 18:35:46; action=VIEW; actionForDisplay=VIEW; notes=; byUserDisplayName=Authentification User; ticketNumber=; recordingStatus=-1;
recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=False; username=Authentification User; application=SecretServerCloud}"
value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Secrets.Audit"."
---> System.Management.Automation.PSInvalidCastException: Cannot convert the "@{id=525028; dateRecorded=01/02/2024 18:35:46; action=VIEW; actionForDisplay=VIEW; notes=;
byUserDisplayName=User; ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=False;
username=Authentification User; application=SecretServerCloud}" value of type "System.Management.Automation.PSCustomObject" to type
"Thycotic.PowerShell.Secrets.Audit".
---> System.InvalidOperationException: The property 'application' was not found for the 'Thycotic.PowerShell.Secrets.Audit' object. The settable properties are: [SecretAuditId
<System.Int32>], [FullName <System.String>], [Action <System.String>], [ActionForDisplay <System.String>], [ByUserDisplayName <System.String>], [DatabaseName <System.String>], [DateRecorded
<System.Nullable1[[System.DateTime, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]>], [HasProxySessionData <System.Boolean>], [Id <System.Int32>], [Notes <System.String>], [RecordingMessage <System.String>], [RecordingSessionId <System.String>], [RecordingStatus <System.Int32>], [Status <System.String>], [TicketNumber <System.String>], [Username <System.String>]. at System.Management.Automation.LanguagePrimitives.CreateMemberNotFoundError(PSObject pso, DictionaryEntry property, Type resultType) at System.Management.Automation.LanguagePrimitives.SetObjectProperties(Object o, IDictionary properties, Type resultType, MemberNotFoundError memberNotFoundErrorAction, MemberSetValueError memberSetValueErrorAction, Boolean enableMethodCall, IFormatProvider formatProvider, Boolean recursion, Boolean ignoreUnknownMembers) at System.Management.Automation.LanguagePrimitives.SetObjectProperties(Object o, PSObject psObject, Type resultType, MemberNotFoundError memberNotFoundErrorAction, MemberSetValueError memberSetValueErrorAction, IFormatProvider formatProvider, Boolean recursion, Boolean ignoreUnknownMembers) --- End of inner exception stack trace --- at System.Management.Automation.LanguagePrimitives.SetObjectProperties(Object o, PSObject psObject, Type resultType, MemberNotFoundError memberNotFoundErrorAction, MemberSetValueError memberSetValueErrorAction, IFormatProvider formatProvider, Boolean recursion, Boolean ignoreUnknownMembers) at System.Management.Automation.LanguagePrimitives.ConvertViaNoArgumentConstructor.Convert(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable, Boolean ignoreUnknownMembers) --- End of inner exception stack trace --- at System.Management.Automation.LanguagePrimitives.ConvertViaNoArgumentConstructor.Convert(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable, Boolean ignoreUnknownMembers) at System.Management.Automation.LanguagePrimitives.ConvertViaNoArgumentConstructor.Convert(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable) at System.Management.Automation.LanguagePrimitives.ConvertTo(Object valueToConvert, Type resultType, Boolean recursion, IFormatProvider formatProvider, TypeTable backupTypeTable) at System.Management.Automation.LanguagePrimitives.ConvertUnrelatedArrays(Object valueToConvert, Type resultType, Boolean recursion, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable) at CallSite.Target(Closure, CallSite, Object) at System.Management.Automation.Interpreter.DynamicInstruction2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
--- End of inner exception stack trace ---
Please run the command using -Verbose
Get-TssSecretAudit -TssSession $session -Id 1115 -Verbose
VERBOSE: Command invocation: get-TssSecretAudit -TssSession:TssSessionObject -Id:System.Int32[] -Verbose:True
VERBOSE: Performing the operation GET https://x/api/v1/secrets/1115/audits?sortBy[0].direction=desc&sortBy[0].name=DateRecorded&take=2147483647
InvalidArgument: C:\PowerShell\Modules\Thycotic.SecretServer\0.61.8\functions\secrets\Get-TssSecretAudit.ps1:76:21
Line |
76 | … [Thycotic.PowerShell.Secrets.Audit[]]$restResponse.record …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot convert value "@{id=525028; dateRecorded=01/02/2024 18:35:46; action=VIEW; actionForDisplay=VIEW; notes=; byUserDisplayName=Authentification User; ticketNumber=; recordingStatus=-1;
| recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=False; username=Authentification User; application=SecretServerCloud}" to type
| "Thycotic.PowerShell.Secrets.Audit". Error: "Cannot convert the "@{id=525028; dateRecorded=01/02/2024 18:35:46; action=VIEW; actionForDisplay=VIEW; notes=; byUserDisplayName=Authentification User; ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=False; username=Authentification User;
| application=SecretServerCloud}" value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Secrets.Audit"."
Provide a test case or steps to reproduce
Get-TssSecretAudit -TssSession $session -Id 1115
Expected behavior
This should return the audit log of the secret but it is throwing a error while doing so.
What Edition of Secret Server?
Cloud Subscription
What version of Secret Server
Secret Server Cloud
What PowerShell host was used when producing this error
Windows PowerShell (powershell)
PowerShell Host Version
PSVersion 7.4.0
Having same problem. PSVersion: 7.4.3 Module version: 0.61.8
Same issue with PSVersion 7.4.2 Module version: 0.61.8
Secret Server on-premises 11.7.000015
Command invocation: Get-TssSecretAudit -TssSession:TssSessionObject -Id:System.Int32[] -IncludePasswordChangeLog:True -Verbose:True Performing the operation GET https://x/api/v1/secrets/95603/audits?sortBy[0].direction=desc&sortBy[0].name=DateRecorded&take=2147483647&filter.includePasswordChangeLog=True InvalidArgument: C:\Users\me\Documents\PowerShell\Modules\Thycotic.SecretServer\0.61.8\functions\secrets\Get-TssSecretAudit.ps1:76:21 Line | 76 | … [Thycotic.PowerShell.Secrets.Audit[]]$restResponse.record … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot convert value "@{id=2643635; dateRecorded=5/24/2024 3:01:29 AM; action=FIELDS DECRYPTED; actionForDisplay=FIELDS DECRYPTED; notes=Scope; byUserDisplayName=ThycoticSystem; | ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=; username=ThycoticSystem; application=}" to type | "Thycotic.PowerShell.Secrets.Audit". Error: "Cannot convert the "@{id=2643635; dateRecorded=5/24/2024 3:01:29 AM; action=FIELDS DECRYPTED; actionForDisplay=FIELDS DECRYPTED; | notes=Scope; byUserDisplayName=ThycoticSystem; ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=; | username=ThycoticSystem; application=}" value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Secrets.Audit"."
Also fails when omitting -IncludePasswordChangeLog
Command invocation: Get-TssSecretAudit -TssSession:TssSessionObject -Id:System.Int32[] -Verbose:True Performing the operation GET https://x/api/v1/secrets/95603/audits?sortBy[0].direction=desc&sortBy[0].name=DateRecorded&take=2147483647 InvalidArgument: C:\Users\me\Documents\PowerShell\Modules\Thycotic.SecretServer\0.61.8\functions\secrets\Get-TssSecretAudit.ps1:76:21 Line | 76 | … [Thycotic.PowerShell.Secrets.Audit[]]$restResponse.record … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot convert value "@{id=2643635; dateRecorded=5/24/2024 3:01:29 AM; action=FIELDS DECRYPTED; actionForDisplay=FIELDS DECRYPTED; notes=Scope; byUserDisplayName=ThycoticSystem; | ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=; username=ThycoticSystem; application=}" to type | "Thycotic.PowerShell.Secrets.Audit". Error: "Cannot convert the "@{id=2643635; dateRecorded=5/24/2024 3:01:29 AM; action=FIELDS DECRYPTED; actionForDisplay=FIELDS DECRYPTED; | notes=Scope; byUserDisplayName=ThycoticSystem; ticketNumber=; recordingStatus=-1; recordingSessionId=; recordingMessage=; databaseName=; status=; hasProxySessionData=; | username=ThycoticSystem; application=}" value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.Secrets.Audit"."
@jagger or @tylerezimmerman It looks like the issue is because https://github.com/thycotic-ps/thycotic.secretserver/blob/dev/src/Thycotic.SecretServer/classes/secrets/Audit.cs class does not have string application which the API returns in the records of a secret audit. Should be an easy fix.