I am currently using the ‘wmic netuse’ to get the smb mappings of a machine. However, the command only returns the mappings for the current user. If I run my script as an administrator it returns nothing.
Is there a way to either:
Run the command in a way that will allow me to see the mappings created by any/all users. OR
Get a list of users, and run the individual command repeatedly as each user.
Thank you ahead of time for your help!
Additional Note: It is prefered that this is Powershell V2.0 compatible. Hence why I am using wmic instead of an SMB-related cmdlet.
OK but whatfor? What do you want to do with the smbmappings once you have them? Are these smbmappings individual ones or are they mapped by GPOs or logon scripts or something like this?
I was asked to create an inventory script which will list the local and remote paths of smbmappings mapped to a machine.
The file will look like this:
“Local Path”, “Remote Path”
“X:”, “\123.456.78.9”
“Z:”,“\987.654.32.1\share”
You could set up a logon script, run net use in that script and save the output to a share or on that local computer to collect the information you’re after.
If you want to get real ugly, you could enumerate all the NTUSER.DAT files on the system and glean the mount points from there. You can only of course do this for users that are not logged in.
When you post code, error messages, sample data or console output format it as code, please.
In the “Text” view you can use the code tags “CODE”, in the “Visual” view you can use the format template “Preformatted”. You can go back edit your post and fix the formatting - you don’t have to create a new one.
Thanks in advance.
If I’m not wrong that would only list the mapped drives for the account you’re running the commands with as well - not the mapped drives of all users of the remote computers, right?
No. A logon script runs when a user logs on to a computer and executes the commands in this script. You would need to wait until all users have logged in at least once.
[quote quote=249722]Hey Jeff,
I do not understand the first line of your code.
Where does this file come from?[/quote]
Jeff commented his code. The first line reads a file containing a list of computers you want to query. I assume that does not fit your requirement.
I cannot wait for users to logon unforunately. This needs to run once upon installation of an app.
And in refernce to Jeff’s comment. I tried the first query (get-Content of that file) but the file could not be found.
That is why I was confused.
Am I creating the file? Or does it already exist on a machine?
Please don’t get me wrong but that sounds like you are quite a beginner with Powershell. The task you choose is not an easy one I’d say. You may take a step back and start with learning the very basics of Powershell first. That will save you from a lot of wasted time and frustration.
It is beyond the scope of this or any forum to develop a custom solution for your requirement and we cannot teach you how to write advanced scripts iteratively in a forum.
You’re correct. I am definitely a beginner.
However, I have been learning a lot on my own time.
In addition, this isn’t for fun (as you might imagine). I’m being asked to do this for work. (aka fustration will be inherent in this task lol).
This forum has been helpful, not in giving me custom solutions but in helping my general understanding.
And specifically to Jeff’s comment, I just didn’t understand what he was refering to.
I don’t mean to sound defensive or offensive with any of this.
Just stating my current situation.
OK, so you will have to find a way to achieve the almost impossible or to find a way around it. You mentioned this should run as a part of an installation of an app. Why would need an app the information about ALL users smb mappings? I’d expect it should be enough to know about the smb mappings of the currently logged on user.
Edit:
And what’s about users logging on after the app was installed?