You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Test-Command cmdlet should be implemented to test whether or not a specified command can be found.
Context
As per issue #7562, more Test- cmdlets should be implemented, specifically Test-Command and Test-Module, as this functionality is desired both generally and for use in the PowerShell tests and build module.
Ilya (@iSazonov) A common pattern is to use the Get-Command cmdlet with the ErrorAction parameter set to SilentlyContinue, although this hides all errors:
Ilya (@iSazonov) well, if you look at the original linked issue #7562, I opened it :)
The discussion in the @PowerShell/powershell-committee on a different topic acknowledged that PowerShell should have had more Test-* cmdlets rather than having scripts rely on Get-* with error handling and checking against $null. Also, with more Test-* cmdlets, it would make it feasible to use cmdlets directly as DSC resources (Get/Set/Test). It's unlikely the PowerShell team would spend the time implementing this. However, this specific cmdlet should be relatively easy and straightforward and would encourage the community to pick it up.
Activity
xtqqczze commentedon Jan 27, 2019
Parameters should be named in common with
Get-Command.iSazonov commentedon Jan 28, 2019
I think it's not worth the effort. You can always use
Get-Commandcmdlet for these purposes.xtqqczze commentedon Jan 28, 2019
Ilya (@iSazonov) A common pattern is to use the
Get-Commandcmdlet with theErrorActionparameter set toSilentlyContinue, although this hides all errors:Alternatively, the specific exception can be caught:
iSazonov commentedon Feb 2, 2019
Steve Lee (@SteveL-MSFT) My suggestion is to close as Won't-Fix - what is your conclusion?
SteveL-MSFT commentedon Feb 6, 2019
Ilya (@iSazonov) well, if you look at the original linked issue #7562, I opened it :)
The discussion in the @PowerShell/powershell-committee on a different topic acknowledged that PowerShell should have had more
Test-*cmdlets rather than having scripts rely onGet-*with error handling and checking against$null. Also, with moreTest-*cmdlets, it would make it feasible to use cmdlets directly as DSC resources (Get/Set/Test). It's unlikely the PowerShell team would spend the time implementing this. However, this specific cmdlet should be relatively easy and straightforward and would encourage the community to pick it up.iSazonov commentedon Feb 6, 2019
Steve Lee (@SteveL-MSFT) Thanks for remainder! So the issue is a duplicate and we can track in #7562.
JamesWTruher commentedon Jun 1, 2021
duplicate of #7562, this is a great discussion with some good detail. We'll refer to it from #7562 when it's time for implementation.