Created
July 1, 2019 18:22
-
-
Save Rhynorater/de75bd225b3b00bc638c9ce7a497fbac to your computer and use it in GitHub Desktop.
Bash script to check if a certain domain is user O365
This file contains 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
#!/bin/bash | |
# Usage checkms.sh | |
# domains.txt: file with domains on each line to check | |
# Output: domains that use O365 | |
# ----- | |
# Usage2 checkms.sh domain.com | |
# Output: domain if uses 0365, nothing if not | |
if [ "$#" -eq 1 ]; then | |
x=$(curl -s -k "https://login.microsoftonline.com/getuserrealm.srf?login=username@$1&xml=1" | egrep "Federated|Managed") | |
if [[ ! -z $x ]]; then | |
echo "$1" | |
fi | |
exit | |
fi | |
for i in `cat domains.txt`; do | |
x=$(curl -s -k "https://login.microsoftonline.com/getuserrealm.srf?login=username@$i&xml=1" | egrep "Federated|Managed") | |
if [[ ! -z $x ]]; then | |
echo "$i" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment