Author Posts

January 24, 2018 at 6:49 pm

Is there a way to put a time out on certain cmdlets like Get-NetIPAddress and GetProcess?

January 24, 2018 at 6:56 pm

Only if the cmdlet directly supports it via a parameter.

January 24, 2018 at 9:18 pm

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..

January 24, 2018 at 9:54 pm

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.

January 24, 2018 at 10:14 pm

Thanks Patrick, I think this works, I'll try it..