multithreading - Calling thread cannot access this object because a different thread owns it -
i trying retrieve list of print queues powershell shown below. getting
the calling thread cannot access object because different thread owns it.
is happeneing because powershell not being able support multiple threads?
is there way around problem?

as far understand, have start powershell -sta (single thread appartment) parameter have code working :
powershell -sta add-type -assemblyname "system.printing" $f = @([system.printing.enumeratedprintqueuetypes]::local, [system.printing.enumeratedprintqueuetypes]::shared) $ps = new-object system.printing.localprintserver $pq = $ps.getprintqueues($f)
Comments
Post a Comment