Share Sizes With Alternative Credentials
-
Monday, February 18, 2013 9:21 PM
Here’s the challenge....
I have been asked to create a script that gathers a list of network shares and their sizes on a given server. A brief search threw up this solution http://stackoverflow.com/questions/2589702/get-total-size-of-all-shared-folders-except-admin-shares-from-a-list-of-server
This solution works in some cases (albeit a bit slow) but I have the added challenge that I want to run the machine with alternative credentials. The machine running the script is on a Workgroup machine and will be run against a range of servers on different domains and some in a workgroup. The problem with the above script is that there doesn’t appear to be a –Credential option for Get-ChildItem, which means I get access denied related messages.
Can anyone offer advice on how to solve this problem?
All Replies
-
Monday, February 18, 2013 9:56 PM
Get -WmiObject Win32_Share -computer somepc -credential
You can only use admin credentials to do this.
¯\_(ツ)_/¯
- Marked As Answer by IamMredMicrosoft Employee, Owner Wednesday, May 01, 2013 4:34 AM
-
Sunday, February 24, 2013 10:39 AMModerator
This probably will not help as WMI just gets the share names, not the size of the share. ALso, you can't run Get-WMIobject on a local machine specifying credentials. Not sure if that was your intention or not, just saying!Get -WmiObject Win32_Share -computer somepc -credential
You can only use admin credentials to do this.
¯\_(ツ)_/¯
Thomas Lee <DoctorDNS@Gmail.Com>
- Marked As Answer by IamMredMicrosoft Employee, Owner Wednesday, May 01, 2013 4:34 AM
-
Sunday, February 24, 2013 10:52 AM
The idea is to get the shares and the underlying folder. Then we use the file system to get the size. The suggestion was to show how to get the share names.
Getting the size would depend on mapping a drive or the IPC share with admin credentials then Get-CildItem would work.
I think the question has been abandoned.
¯\_(ツ)_/¯
- Marked As Answer by IamMredMicrosoft Employee, Owner Wednesday, May 01, 2013 4:34 AM

