Hello KM,
You should avoid using variables in the Name parameter of Get-AutomationPSCredential. Their use can complicate the discovery of dependencies between runbooks or DSC configurations and credential assets at design time.
Check out the below link for cmdlets
A similar topic is discussed in the below link, do have a look at it for better understanding.
---------------------------------------------------------------------------------------------------
Hope this answers all your queries, if not please do repost back.
If an Answer is helpful, please click "Accept Answer" and upvote it : )