I used below Powershell script to check the mapped drives on remote PCs. Some PC gives the desired result but some does not.
Get-WmiObject Win32_MappedLogicalDisk -computer HW059 | select name, providername
The account I am using got the same administrator right on all the PCs so I don't think the issue is due to the user privilege.
I am wondering if there is any services need to be started / relevant to the script? I checked that WMI service is running on all the PCs.
Sorry that I am new to scripting. Would someone please help? Powershell result
Mapped drives are feature of user session, they do not exist by default on a system. Even if all users would have same disk mapped (i.e. S: mapped to \\server\share), S: would not exist there if there is no logged in user.
Please see remarks from MSDN (you are user A in description below)
The instances returned for this class are as follows, supposing that user A is enumerating the instances:
The provider looks for a logon session of user A on that machine: If there is one (and only one) such logon session, then the provider returns the mapped drives of that session. If there is more than one session for user A on the machine, then no mapped drive instances are returned (because the provider has no reasonable way of deciding which session to use).
If there are no sessions of user A running, and there is a locally logged on user B:
If there is a single session for user B, then the provider impersonates A and returns the mapped drives of user B. This case supports the scenario of Helpdesk wanting to see the instances of a locally logged on user. However, whether instances are returned depends on the Local Security Policy settings in the Control Panel Administrative Tools. If the following policy is set to "Object Creator", then no mapped drive instances are returned, even if A is a member of the Administrators group: "System object: default owner for objects created by members of the administrators group." Again, if there is more than one session of user B running on the machine, then the provider has no way of deciding which to use. In this case, no mapped drive instances are returned.