Author Posts

September 5, 2014 at 2:57 pm

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

September 5, 2014 at 3:04 pm

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.

September 5, 2014 at 6:52 pm

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?

September 6, 2014 at 7:10 am

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.

September 6, 2014 at 3:13 pm

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