Skip to content

Commit 0356966

Browse files
committed
Cleanup old
1 parent b672ec6 commit 0356966

File tree

2 files changed

+19
-188
lines changed

2 files changed

+19
-188
lines changed

Entra/Connect-MSGraph.ps1

Lines changed: 0 additions & 67 deletions
This file was deleted.

Entra/M365 Service URLs.ps1

Lines changed: 19 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# I just found this old script that was horribly written and am slowly fixing it up. 😅
2+
13
<#
24
.SYNOPSIS
35
An experimental way to get the list of URLs used by Microsoft 365 services.
@@ -36,176 +38,72 @@
3638
https://docs.microsoft.com/en-us/graph/deployments
3739
#>
3840

39-
# $Guid = New-Guid
40-
[Guid]$global:Guid = 'f31523fa-cb44-44e6-9a13-037a0643e282'
41+
[guid]$Guid = 'f31523fa-cb44-44e6-9a13-037a0643e282'
4142

4243
function Get-InstanceNames {
4344
# Get a list of available cloud instance names (gov, foreign, worldwide, etc) using a GUID for the request.
4445
$UriInstanceNames = "https://endpoints.office.com/version?clientrequestid=$Guid"
45-
$global:InstanceNames = ( ( (Invoke-WebRequest -Uri $UriInstanceNames).Content ) | ConvertFrom-Json ).instance
46+
$InstanceNames = ( ( (Invoke-WebRequest -Uri $UriInstanceNames).Content ) | ConvertFrom-Json ).instance
47+
return $InstanceNames
4648
} # End function Get-InstanceNames
4749

48-
Get-InstanceNames
49-
5050
function Get-ServiceAreas {
5151
# Get all service area names for a given instance.
5252
[CmdletBinding()]
5353
param (
5454
[Parameter(Mandatory = $true)]
5555
[ArgumentCompleter({
5656
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
57-
if (!($global:InstanceNames)) {
57+
if (!($InstanceNames)) {
5858
Get-InstanceNames
5959
} else {
60-
Return $global:InstanceNames
60+
return $InstanceNames
6161
}
6262
})]
6363
[string]
6464
$Instance
6565
)
6666

67-
$Uri = "https://endpoints.office.com/endpoints/$Instance" + "?clientrequestid=$Guid"
68-
$global:ServiceAreas = ( ( ((Invoke-WebRequest -Uri $Uri).Content) | ConvertFrom-Json ) | Select-Object serviceArea -Unique).servicearea
69-
Return $global:ServiceAreas
67+
$Uri = "https://endpoints.office.com/endpoints/$Instance" + "?ClientRequestId=$Guid"
68+
$ServiceAreas = ( ( ((Invoke-WebRequest -Uri $Uri).Content) | ConvertFrom-Json ) | Select-Object serviceArea -Unique).ServiceArea
69+
return $ServiceAreas
7070
} # End function Get-ServiceAreas
7171

7272
function Get-ServiceUrls {
7373
# Get all service URLs for a selected instance and service area.
7474
[CmdletBinding()]
7575
param (
76-
[Parameter(Mandatory = $true)]
76+
[Parameter()]
7777
[ArgumentCompleter({
7878
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
79-
if (!($global:InstanceNames)) {
79+
if (!($InstanceNames)) {
8080
Get-InstanceNames
8181
} else {
82-
Return $global:InstanceNames
82+
return $InstanceNames
8383
}
8484
})]
8585
[string]
86-
$Instance,
86+
$Instance = 'Worldwide',
8787
[ArgumentCompleter(
8888
{
8989
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
90-
if (!($global:InstanceNames)) {
90+
if (!($InstanceNames)) {
9191
Get-InstanceTypes
9292
} elseif (!($ServiceAreas)) {
9393
if (!($Instance)) {
9494
$Instance = 'Worldwide'
9595
}
9696
Get-ServiceAreas -InstanceName $Instance
9797
} else {
98-
Return $global:ServiceAreas
98+
return $ServiceAreas
9999
}
100100
}
101101
)]
102102
[string]
103103
$ServiceArea
104104
)
105105

106-
$Uri = "https://endpoints.office.com/endpoints/$Instance" + "?clientrequestid=$Guid" + '&' + "serviceArea=$ServiceArea"
107-
$global:ServiceUrls = ( ( ((Invoke-WebRequest -Uri $Uri).Content) | ConvertFrom-Json ) | Select-Object urls -Unique).urls
108-
Return $global:ServiceUrls
106+
$Uri = "https://endpoints.office.com/endpoints/$Instance" + "?ClientRequestId=$Guid" + '&' + "serviceArea=$ServiceArea"
107+
$ServiceUrls = ( ( ((Invoke-WebRequest -Uri $Uri).Content) | ConvertFrom-Json ) | Select-Object urls -Unique).urls
108+
return $ServiceUrls
109109
}
110-
111-
112-
#region Appendix
113-
114-
<# SCRATCH PAD
115-
# Fun, but probably not necessary:
116-
[Guid]$global:Guid = "f31523fa-cb44-44e6-9a13-037a0643e282"
117-
$UriInstanceNames = "https://endpoints.office.com/version?clientrequestid=$Guid"
118-
$global:InstanceNames = ( ( (Invoke-WebRequest -Uri $UriInstanceNames).Content ) | ConvertFrom-Json ).instance
119-
120-
foreach ($item in $InstanceNames) {
121-
$VariableName = '$Endpoints'+"$item"
122-
$Expression = "$Variablename = " + '"' + "https://endpoints.office.com/endpoints/"+"$item"+"?clientrequestid=$($Guid)" + '"'
123-
Invoke-Expression $Expression
124-
Write-Output `n"A new URI variable has been created for $item : " $Expression
125-
}
126-
127-
#>
128-
129-
# SAMPLE JSON DATA
130-
<# SAMPLE INSTANCE OUTPUT
131-
[
132-
{
133-
"instance": "Worldwide",
134-
"latest": "2021102900"
135-
},
136-
{
137-
"instance": "USGovDoD",
138-
"latest": "2021102900"
139-
},
140-
{
141-
"instance": "USGovGCCHigh",
142-
"latest": "2021102900"
143-
},
144-
{
145-
"instance": "China",
146-
"latest": "2021092800"
147-
},
148-
{
149-
"instance": "Germany",
150-
"latest": "2021102900"
151-
}
152-
]
153-
#>
154-
155-
<# SAMPLE GCCHIGH OUTPUT
156-
[
157-
{
158-
"id": 1,
159-
"serviceArea": "Exchange",
160-
"serviceAreaDisplayName": "Exchange Online",
161-
"urls": [
162-
"outlook.office365.us"
163-
],
164-
"ips": [
165-
"20.35.208.0/20",
166-
"20.35.240.0/21",
167-
"40.66.16.0/21",
168-
"131.253.83.0/26",
169-
"131.253.84.64/26",
170-
"131.253.84.192/26",
171-
"131.253.86.0/24",
172-
"131.253.87.144/28",
173-
"131.253.87.208/28",
174-
"131.253.87.240/28",
175-
"131.253.88.0/28",
176-
"131.253.88.32/28",
177-
"131.253.88.48/28",
178-
"131.253.88.96/28",
179-
"131.253.88.128/28",
180-
"131.253.88.144/28",
181-
"131.253.88.160/28",
182-
"131.253.88.192/28",
183-
"131.253.88.240/28",
184-
"2001:489a:2200:28::/62",
185-
"2001:489a:2200:3c::/62",
186-
"2001:489a:2200:44::/62",
187-
"2001:489a:2200:58::/61",
188-
"2001:489a:2200:60::/62",
189-
"2001:489a:2200:79::/64",
190-
"2001:489a:2200:7d::/64",
191-
"2001:489a:2200:7f::/64",
192-
"2001:489a:2200:80::/64",
193-
"2001:489a:2200:82::/63",
194-
"2001:489a:2200:86::/64",
195-
"2001:489a:2200:88::/63",
196-
"2001:489a:2200:8a::/64",
197-
"2001:489a:2200:8c::/64",
198-
"2001:489a:2200:8f::/64",
199-
"2001:489a:2200:100::/56",
200-
"2001:489a:2200:400::/56",
201-
"2001:489a:2200:600::/56"
202-
],
203-
"tcpPorts": "80,443",
204-
"expressRoute": true,
205-
"category": "Optimize",
206-
"required": true
207-
}
208-
]
209-
#>
210-
211-
#endregion Appendix

0 commit comments

Comments
 (0)