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

Tagged: 

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Jarom Later Jarom Later 2 years, 3 months ago.

  • Author
    Posts
  • #18568
    Profile photo of Jarom Later
    Jarom Later
    Participant

    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
    
  • #18569
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.

  • #18571
    Profile photo of Jarom Later
    Jarom Later
    Participant

    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?

  • #18575
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.

  • #18582
    Profile photo of Jarom Later
    Jarom Later
    Participant

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

You must be logged in to reply to this topic.