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

Welcome Forums General PowerShell Q&A Unable to retrieve default printers and mapped drives using CIM on remote PC's

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
4 years, 3 months ago.

  • Author
    Posts
  • #18568

    Participant
    Points: 0
    Rank: Member

    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

    Keymaster
    Points: 1,674
    Helping HandTeam Member
    Rank: Community Hero

    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

    Participant
    Points: 0
    Rank: Member

    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

    Keymaster
    Points: 1,674
    Helping HandTeam Member
    Rank: Community Hero

    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

    Participant
    Points: 0
    Rank: Member

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

The topic ‘Unable to retrieve default printers and mapped drives using CIM on remote PC's’ is closed to new replies.