Last active
May 12, 2022 21:56
-
-
Save m87carlson/9fec746dd0cbac1c36fd to your computer and use it in GitHub Desktop.
user-profiles.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import re | |
import platform | |
def user_profiles(): | |
""" | |
local_users grain will list the contents of: | |
Unix: | |
/home | |
Windows: | |
7: | |
c:\Users\ | |
XP: | |
c:\Documents and Settings\ | |
""" | |
grains = {} | |
if platform.system() == 'Windows': | |
if platform.win32_ver()[1].startswith('5'): | |
profile_path = r'c:\Documents and Settings' | |
elif platform.win32_ver()[1].startswith('6'): | |
profile_path = r'c:\Users' | |
elif platform.system() == ('FreeBSD' or 'Linux'): | |
profile_path = '/home' | |
users = os.listdir(profile_path) | |
grains['user_profiles'] = users | |
return grains |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment