简体   繁体   中英

powershell's Get-WmiObject -Class Win32_Share returns null paths

im trying to get a list of shares and thier paths from a remote server using powershell, as below (servername obviscated)

Get-WmiObject -Class Win32_Share -ComputerName servername

This retuns the list of shares from the remote machine, but the share path attribute is null for every row, unless I add the account im using to the local administrators group on the remote machine in which case it returns the path values.

Can anyone help me work out what specific permissions might be required?

This is what i've tried so far; -adding to remote servers 'performance monitor users' group -adding the account to the COM security access permissions & lauch and activation permissions -adding the account to the DCOM Windows Management and Instrumentation Launch and Activation Permissions

By running this command with a non admin account, you will get null and it will not return the path for it by design. Looking over the following technet article what describes this class :

Win32_Share class http://msdn.microsoft.com/en-us/library/aa394435(v=vs.85).aspx

Remarks The Win32_Share class is derived from CIM_LogicalElement. The Create method in this class is a static method. The Delete, GetAccessMask and SetShareInfo methods are all instance methods. Depending on your security permissions, you may not be able to retrieve all of the properties of this class. For example, AllowMaximum, MaximumAllowed, Path, and Type properties may return null. Generally speaking, Power Users and Administrators will be able to retrieve all property values.

With other words, this is by design as it should . As non admin the you should not have everything returned as an admin account.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM