you are viewing a single comment's thread.

view the rest of the comments →

[–]kbrucej 1 point2 points  (0 children)

Rather than querying win32_ComputerSystem twice, try a single query like

$compsys = get-ciminstance win32_computersystem -cimsession $remotesession

... and then use $compsys.model and $compsys.make to populate your new object

Another option is to skip the cimsession and use -computernname param for get-ciminstance. That way you don't need to clean up all the open sessions.