Is there a way to put a time out on certain cmdlets like Get-NetIPAddress and GetProcess?
Only if the cmdlet directly supports it via a parameter.
Well, what I’ve done in similar situations in the past is find the underlying WMI call for example, and write a function that would provide things the native cmdlet does not like time-out. I try to not write proxy functions for obvious reasons…
For example,
Install-Module SB-Tools,POSH-SSH -Force Import-Module SB-Tools -DisableNameChecking (Get-Command Get-SBWMI).Definition
will show the Get-SBWMI function which provides a TimeOut parameter
I was hoping someone has done that already…
For CIM based commands you can use a cimsession with a timeout
$cimSession = New-CimSession -OperationTimeoutSec 1 Get-NetIPAddress -CimSession $cimSession
Not in general though.
Thanks Patrick, I think this works, I’ll try it…