Renew Filevault key script failing

Rob_Jamf
New Contributor II

Hi,
I'm using this script and I've tested on a VM 10.15.7 and it works perfectly. I'm getting loads of these errors with users on the same MacOS version now that I've gone live. Any ideas what's making it fail? If I publish it in the self support portal it runs fine.

https://github.com/jamf/FileVault2_Scripts/blob/master/reissueKey.sh

Error:

Executing Policy Re-issue recovery key (SCRIPT)
Running script Issue New FileVault  Key...
Script exit code: 0
Script result: Prompting user for their login password.
2021-03-22 13:26:25.304 osascript[25525:3490926] -[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0
2021-03-22 13:26:25.313 osascript[25525:3490926] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff39b00b57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff7294c5bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff39b7fbe7 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff39a653bb ___forwarding___ + 1427
    4   CoreFoundation                      0x00007fff39a64d98 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x00007fff39a33ed7 CFArrayContainsValue + 197
    6   HIServices                          0x00007fff37d3a7b9 TransformProcessType + 927
    7   osascript                           0x000000010773402c osascript + 12332
    8   HIToolbox                           0x00007fff3874f7c5 AEInteractWithUser + 53
    9   StandardAdditions                   0x000000010a2e68b9 CSDSTEXTurl_ + 5865
    10  StandardAdditions                   0x000000010a2d7331 AEVTsysodlog + 85
    11  AE                                  0x00007fff3adf7203 _AppleEventsCheckInAppWithBlock + 18103
    12  AE                                  0x00007fff3ae06c83 AESendMessage + 2838
    13  AE                                  0x00007fff3ae12fb1 aeSend + 355
    14  osascript                           0x0000000107732b25 osascript + 6949
    15  AppleScript                         0x00007fff4d91a342 _Z13ComponentSendPK6AEDescPS_ii + 485
    16  AppleScript                         0x00007fff4d92bf0a _ZN15TUASApplication4SendEP25TStackFrame_UASRemoteSendP6AEDescS3_hhh + 2332
    17  AppleScript                         0x00007fff4d94cca7 _Z13UASRemoteSendhhhhhPh + 548
    18  AppleScript                         0x00007fff4d9251f0 _Z13UASActor_Sendhhh + 383
    19  AppleScript                         0x00007fff4d958402 _Z13UASValue_Sendhh14TUASClassIndexh + 326
    20  AppleScript                         0x00007fff4d92fff9 _Z11UASExecute1v + 288
    21  AppleScript                         0x00007fff4d903b26 _Z14ASExecuteEventPK6AEDescjiPj + 614
    22  AppleScript                         0x00007fff4d8fc971 AppleScriptComponent + 1677
    23  AppleScript                         0x00007fff4d915bdb _ZN12AGenericCall8DelegateEP23ComponentInstanceRecord + 37
    24  AppleScript                         0x00007fff4d915ba1 _ZN15AGenericManager13HandleOSACallEP19ComponentParameters + 57
    25  AppleScript                         0x00007fff4d91518c GenericComponent + 156
    26  OpenScripting                       0x00007fff389923e2 OSAExecuteEvent + 50
    27  osascript                           0x00000001077335bd osascript + 9661
    28  libdyld.dylib                       0x00007fff73af4cc9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Error Changing Key

 Error: Password is required.
 Error: User could not be authenticated.
 Error: Unable to unlock or authenticate to FileVault.

2021-03-22 13:26:35.813 osascript[25533:3491178] -[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0
2021-03-22 13:26:35.815 osascript[25533:3491178] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff39b00b57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff7294c5bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff39b7fbe7 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff39a653bb ___forwarding___ + 1427
    4   CoreFoundation                      0x00007fff39a64d98 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x00007fff39a33ed7 CFArrayContainsValue + 197
    6   HIServices                          0x00007fff37d3a7b9 TransformProcessType + 927
    7   osascript                           0x000000010c0b102c osascript + 12332
    8   HIToolbox                           0x00007fff3874f7c5 AEInteractWithUser + 53
    9   StandardAdditions                   0x000000010ed6a8b9 CSDSTEXTurl_ + 5865
    10  StandardAdditions                   0x000000010ed5b331 AEVTsysodlog + 85
    11  AE                                  0x00007fff3adf7203 _AppleEventsCheckInAppWithBlock + 18103
    12  AE                                  0x00007fff3ae06c83 AESendMessage + 2838
    13  AE                                  0x00007fff3ae12fb1 aeSend + 355
    14  osascript                           0x000000010c0afb25 osascript + 6949
    15  AppleScript                         0x00007fff4d91a342 _Z13ComponentSendPK6AEDescPS_ii + 485
    16  AppleScript                         0x00007fff4d92bf0a _ZN15TUASApplication4SendEP25TStackFrame_UASRemoteSendP6AEDescS3_hhh + 2332
    17  AppleScript                         0x00007fff4d94cca7 _Z13UASRemoteSendhhhhhPh + 548
    18  AppleScript                         0x00007fff4d9251f0 _Z13UASActor_Sendhhh + 383
    19  AppleScript                         0x00007fff4d958402 _Z13UASValue_Sendhh14TUASClassIndexh + 326
    20  AppleScript                         0x00007fff4d92fff9 _Z11UASExecute1v + 288
    21  AppleScript                         0x00007fff4d903b26 _Z14ASExecuteEventPK6AEDescjiPj + 614
    22  AppleScript                         0x00007fff4d8fc971 AppleScriptComponent + 1677
    23  AppleScript                         0x00007fff4d915bdb _ZN12AGenericCall8DelegateEP23ComponentInstanceRecord + 37
    24  AppleScript                         0x00007fff4d915ba1 _ZN15AGenericManager13HandleOSACallEP19ComponentParameters + 57
    25  AppleScript                         0x00007fff4d91518c GenericComponent + 156
    26  OpenScripting                       0x00007fff389923e2 OSAExecuteEvent + 50
    27  osascript                           0x000000010c0b05bd osascript + 9661
    28  libdyld.dylib                       0x00007fff73af4cc9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
/Library/Application Support/JAMF/tmp/Issue New FileVault  Key: line 191: 25533 Abort trap: 6           /usr/bin/osascript -e "
on run
display dialog "FileVault Key not Changed" & return & "$result" buttons {"Cancel", "Try Again"} default button 2 with title "$orgName FileVault Key Reset" with icon POSIX file "$brandIcon"
end run"
Prompting username for their login password.
2021-03-22 13:26:36.438 osascript[25534:3491210] -[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0
2021-03-22 13:26:36.439 osascript[25534:3491210] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff39b00b57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff7294c5bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff39b7fbe7 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff39a653bb ___forwarding___ + 1427
    4   CoreFoundation                      0x00007fff39a64d98 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x00007fff39a33ed7 CFArrayContainsValue + 197
    6   HIServices                          0x00007fff37d3a7b9 TransformProcessType + 927
    7   osascript                           0x000000010437e02c osascript + 12332
    8   HIToolbox                           0x00007fff3874f7c5 AEInteractWithUser + 53
    9   StandardAdditions                   0x0000000106f308b9 CSDSTEXTurl_ + 5865
    10  StandardAdditions                   0x0000000106f21331 AEVTsysodlog + 85
    11  AE                                  0x00007fff3adf7203 _AppleEventsCheckInAppWithBlock + 18103
    12  AE                                  0x00007fff3ae06c83 AESendMessage + 2838
    13  AE                                  0x00007fff3ae12fb1 aeSend + 355
    14  osascript                           0x000000010437cb25 osascript + 6949
    15  AppleScript                         0x00007fff4d91a342 _Z13ComponentSendPK6AEDescPS_ii + 485
    16  AppleScript                         0x00007fff4d92bf0a _ZN15TUASApplication4SendEP25TStackFrame_UASRemoteSendP6AEDescS3_hhh + 2332
    17  AppleScript                         0x00007fff4d94cca7 _Z13UASRemoteSendhhhhhPh + 548
    18  AppleScript                         0x00007fff4d9251f0 _Z13UASActor_Sendhhh + 383
    19  AppleScript                         0x00007fff4d958402 _Z13UASValue_Sendhh14TUASClassIndexh + 326
    20  AppleScript                         0x00007fff4d92fff9 _Z11UASExecute1v + 288
    21  AppleScript                         0x00007fff4d903b26 _Z14ASExecuteEventPK6AEDescjiPj + 614
    22  AppleScript                         0x00007fff4d8fc971 AppleScriptComponent + 1677
    23  AppleScript                         0x00007fff4d915bdb _ZN12AGenericCall8DelegateEP23ComponentInstanceRecord + 37
    24  AppleScript                         0x00007fff4d915ba1 _ZN15AGenericManager13HandleOSACallEP19ComponentParameters + 57
    25  AppleScript                         0x00007fff4d91518c GenericComponent + 156
    26  OpenScripting                       0x00007fff389923e2 OSAExecuteEvent + 50
    27  osascript                           0x000000010437d5bd osascript + 9661
    28  libdyld.dylib                       0x00007fff73af4cc9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Error Changing Key
2021-03-22 13:26:46.970 osascript[25543:3491579] -[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0
2021-03-22 13:26:46.971 osascript[25543:3491579] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x7fff913330e0'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff39b00b57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff7294c5bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff39b7fbe7 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff39a653bb ___forwarding___ + 1427
    4   CoreFoundation                      0x00007fff39a64d98 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x00007fff39a33ed7 CFArrayContainsValue + 197
    6   HIServices                          0x00007fff37d3a7b9 TransformProcessType + 927
    7   osascript                           0x0000000106d9302c osascript + 12332
    8   HIToolbox                           0x00007fff3874f7c5 AEInteractWithUser + 53
    9   StandardAdditions                   0x0000000107dfa8b9 CSDSTEXTurl_ + 5865
    10  StandardAdditions                   0x0000000107deb331 AEVTsysodlog + 85
    11  AE                                  0x00007fff3adf7203 _AppleEventsCheckInAppWithBlock + 18103
    12  AE                                  0x00007fff3ae06c83 AESendMessage + 2838
    13  AE                                  0x00007fff3ae12fb1 aeSend + 355
    14  osascript                           0x0000000106d91b25 osascript + 6949
    15  AppleScript                         0x00007fff4d91a342 _Z13ComponentSendPK6AEDescPS_ii + 485
    16  AppleScript                         0x00007fff4d92bf0a _ZN15TUASApplication4SendEP25TStackFrame_UASRemoteSendP6AEDescS3_hhh + 2332
    17  AppleScript                         0x00007fff4d94cca7 _Z13UASRemoteSendhhhhhPh + 548
    18  AppleScript                         0x00007fff4d9251f0 _Z13UASActor_Sendhhh + 383
    19  AppleScript                         0x00007fff4d958402 _Z13UASValue_Sendhh14TUASClassIndexh + 326
    20  AppleScript                         0x00007fff4d92fff9 _Z11UASExecute1v + 288
    21  AppleScript                         0x00007fff4d903b26 _Z14ASExecuteEventPK6AEDescjiPj + 614
    22  AppleScript                         0x00007fff4d8fc971 AppleScriptComponent + 1677
    23  AppleScript                         0x00007fff4d915bdb _ZN12AGenericCall8DelegateEP23ComponentInstanceRecord + 37
    24  AppleScript                         0x00007fff4d915ba1 _ZN15AGenericManager13HandleOSACallEP19ComponentParameters + 57
    25  AppleScript                         0x00007fff4d91518c GenericComponent + 156
    26  OpenScripting                       0x00007fff389923e2 OSAExecuteEvent + 50
    27  osascript                           0x0000000106d925bd osascript + 9661
    28  libdyld.dylib                       0x00007fff73af4cc9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
/Library/Application Support/JAMF/tmp/Issue New FileVault  Key: line 205: 25543 Abort trap: 6           /usr/bin/osascript -e "
on run
display dialog "FileVault Key not changed" & return & "$haltMsg" buttons {"Close"} default button 1 with title "$orgName FileVault Key Reset" with icon POSIX file "$brandIcon"
end run
"
Quitting.. Too Many failures
5 REPLIES 5

user-qDkaLQXSEB
New Contributor

I'm having exactly the same issue. Were you able to find a solution?

Rob_Jamf
New Contributor II

Hi, I found that publishing the script as self service and getting the users to click it manually fixed resolved my issue. I only had about 20 macs to finish so it was ok. Guess this would be a pain if you had lots to do.

thomas_moser
New Contributor III

Hi,
as we are running in the same issue I looked if there was already an answer and found this:
https://www.jamf.com/jamf-nation/discussions/36463/osascript-errors

But I am not sure on how to integrate it into the current script (https://github.com/jamf/FileVault2_Scripts/blob/master/reissueKey.sh).
Since I am not a pro at scripting :)

taylorducharme
New Contributor III

I have the same issue, the only thing that I can figure is if the jamf account doesn’t have a secure token then it won’t work. This policy only has issues when we’ve acquired a company and when we enroll them in our jamf instance and forget to give our jamf account the secure token is when it fails.

thomas_moser
New Contributor III

Hi taylorducharme,
in our case the account is not the issue, as we do not use our jamf account for reissuing the key.
The original script located at github is not using the jamf account either. It should use the account of the user logged in at the time the script runs. In our case these are all with secure token.
The script apparently fails at asking the user for his credentials. Since the popup does not appear reliable. It runs into a problem and we will see the error above in the logs.
If the popup appears at the device and the user enters her/his credentials everything works fine.