-
-
Save krispayne/0ffa0af13e2a7422a5074836b57ced73 to your computer and use it in GitHub Desktop.
Get IP Address for all computers in the JSS
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
#!/usr/bin/env python | |
"""https://twitter.com/krispayne/status/859833552078225408: | |
@shea_craig is possible with python-jss to generate a list of IP addresses for | |
computers in the JSS? | |
""" | |
from operator import itemgetter | |
# This example uses python-jss 2.0.0+ | |
import jss | |
def main(): | |
# Configure the JSS API object. Fill in with your information. | |
# You will need the add the JSS' certificate to your keychain and trust | |
# it. | |
j = jss.JSS( | |
url="https://jss.com:8443", user="python-jss", password="password", | |
ssl_verify=True) | |
# Alternate form, if you have built preferences already (see the docs): | |
# j = jss.JSS(jss.JSSPrefs()) | |
# Query the JSS for all Computer objects. We use the subset argument to | |
# minimize the amount of data retrieved to just the 'general' data, | |
# which includes IP address. | |
#computers = j.Computer(subset='general') | |
computers = j.Computer() | |
# Build a list of the IP address value from each computer's general | |
# section. You can descend the tag tree with dot syntax notation. | |
ip_addresses = [comp.general.last_reported_ip.text for comp in computers] | |
# Get Departments | |
#departments = [comp.location.department.text for comp in computers] | |
# Show it! | |
print '[usermachines]' | |
for index, ip_address in enumerate(ip_addresses): | |
print ip_address | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment