Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Input Globals
$username = "user@sipdomian.com.au"
$password = "password"
$s4bAutodiscover = "https://lyncdiscover.customer.com.au"
$pwd = $password | convertto-securestring -AsPlainText -Force
write-verbose "Get S4B Autodiscover Information"
try{
$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
}catch{
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"
try{
$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
}catch{
write-output "We couldn't AuthN with the username & password provided. Update and try again."
exit 1
}
write-verbose "Get application URLs"
try{
$data = Invoke-WebRequest -Uri "$oauthurl" -Method GET -Headers @{"Authorization"="Bearer $authcwt"} -UseBasicParsing
$rootappurl = ($data.content | ConvertFrom-JSON)._links.applications.href
}catch{
write-output "Unable to get Application URLs"
exit 1
}
@DollarAkshay

This comment has been minimized.

DollarAkshay commented Mar 27, 2018

Came from your article here

what should i replace "https://lyncdiscover.customer.com.au" with ?
I have already tried "http://lyncdiscover.betsol.com" and "https://lyncdiscover.betsol.com", they both did not work

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

@darrenjrobinson

This comment has been minimized.

Owner

darrenjrobinson commented Mar 27, 2018

Our's for example is https://lyncdiscover.kloud.com.au
What is your SIP address? Same as your email address user@betsol.com ? 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