Unable to retrieve default printers and mapped drives using CIM on remote PC's

Here’s what I have going on. For some reason when I run these commands locally they work fine, but if I run them on remote machines nothing happens. I’ve tried using “get-wmiobject” too. Same thing. Any thoughts on why this could be? Thanks!

$cimopt = New-CimSessionOption -Protocol DCOM
$cimsession = New-CimSession -ComputerName $computerhostname -SessionOption $cimopt

#### printers
get-ciminstance -cimsession $cimsession -ClassName Win32_Printer
get-ciminstance -cimsession $cimsession -ClassName win32_printer | %{if ($_.default) {$_}}

#### mapped drives
get-ciminstance -cimsession $cimsession -ClassName Win32_MappedLogicalDisk

That’s because when You connect remotely, you do not have a profile. Therefore, you would not have mapped drives, or mapped printers. Not really any way around that - CIM isn’t a full desktop login.

Thanks for the reply, Don. Would there be a solution to pull the mapped drives and printers from the logged in user of a remote computer?

It’d need to run in the users context, which makes remote almost impossible. Run a logon script and log the results somewhere central maybe.

Well, that’s good to know. I’ll just take Paul McCartney’s advice and let it be. :wink: Thanks for taking the time answering my questions. .