Instantly share code, notes, and snippets.

What would you like to do?
# Input Globals
$username = ""
$password = "password"
$s4bAutodiscover = ""
$pwd = $password | convertto-securestring -AsPlainText -Force
write-verbose "Get S4B Autodiscover Information"
$data = Invoke-WebRequest -Uri $s4bAutodiscover -Method GET -ContentType "application/json" -UseBasicParsing
$baseurl = (($data.content | ConvertFrom-JSON)._links.user.href).split("/")[0..2] -join "/"
$oauthurl = ($data.content | convertfrom-json)._links.user.href
write-output "Could not retrieve S4B Autodiscover information on" $s4bAutodiscover "Change the S4B Autodiscover URL and try again"
exit 1
write-verbose "AuthN to S4B to get oAuth Token"
$postParams = @{grant_type="password";username=$username;password=$password}
$data = Invoke-WebRequest -Uri "$baseurl/WebTicket/oauthtoken" -Method POST -Body $postParams -UseBasicParsing
$authcwt = ($data.content | ConvertFrom-JSON).access_token
write-output "We couldn't AuthN with the username & password provided. Update and try again."
exit 1
write-verbose "Get application URLs"
$data = Invoke-WebRequest -Uri "$oauthurl" -Method GET -Headers @{"Authorization"="Bearer $authcwt"} -UseBasicParsing
$rootappurl = ($data.content | ConvertFrom-JSON)._links.applications.href
write-output "Unable to get Application URLs"
exit 1

This comment has been minimized.

DollarAkshay commented Mar 27, 2018

Came from your article here

what should i replace "" with ?
I have already tried "" and "", they both did not work

I have an email id like "", so how do i find my CNAME and SRV S4B DNS settings ?


This comment has been minimized.


darrenjrobinson commented Mar 27, 2018

Our's for example is
What is your SIP address? Same as your email address ? Try checking via nslookup to validate the URL when you think you've worked out what it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment