├── LICENSE
├── PowerShellO365Dash.ps1
└── README.md
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Bradley Wyatt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/PowerShellO365Dash.ps1:
--------------------------------------------------------------------------------
1 | Function New-GraphToken
2 | {
3 | #Requires -Module AzureRM
4 | [CmdletBinding()]
5 | Param (
6 | $TenantName = 'bwya77.onmicrosoft.com'
7 | )
8 |
9 | try
10 | {
11 | Import-Module AzureRM -ErrorAction Stop
12 | }
13 | catch
14 | {
15 | Write-Error 'Can''t load AzureRM module.'
16 | break
17 | }
18 |
19 | $clientId = "1950a258-227b-4e31-a9cf-717495945fc2" #PowerShell ClientID
20 | $redirectUri = "urn:ietf:wg:oauth:2.0:oob"
21 | $resourceAppIdURI = "https://graph.windows.net"
22 | $authority = "https://login.windows.net/$TenantName"
23 | $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
24 | #$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId,$redirectUri, "Auto")
25 | $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Always")
26 |
27 | @{
28 | 'Content-Type' = 'application\json'
29 | 'Authorization' = $authResult.CreateAuthorizationHeader()
30 | }
31 | }
32 |
33 | $TenantName = "bwya77.onmicrosoft.com"
34 | $GraphToken = New-GraphToken -TenantName $TenantName
35 |
36 | $Colors = @{
37 | BackgroundColor = "#FF252525"
38 | FontColor = "#FFFFFFFF"
39 | }
40 |
41 | $NavBarLinks = @((New-UDLink -Text "favorite_border PowerShell Pro Tools" -Url "https://poshtools.com/buy-powershell-pro-tools/"),
42 | (New-UDLink -Text "description Documentation" -Url "https://adamdriscoll.gitbooks.io/powershell-tools-documentation/content/powershell-pro-tools-documentation/about-universal-dashboard.html"))
43 |
44 |
45 | Start-UDDashboard -Wait -Port 8081 -Content {
46 | New-UDDashboard -NavbarLinks $NavBarLinks -Title "Office 365 Dashboard" -NavBarColor '#FF1c1c1c' -NavBarFontColor "#FF55b3ff" -BackgroundColor "#FF333333" -FontColor "#FFFFFFF" -Content {
47 | New-UDRow{
48 | New-UDColumn -Size 4 {
49 | New-UDMonitor -Title "Total Users" -Type Line -DataPointHistory 20 -RefreshInterval 15 -ChartBackgroundColor '#5955FF90' -ChartBorderColor '#FF55FF90' @Colors -Endpoint {
50 | (Invoke-RestMethod -Uri "https://graph.windows.net/$TenantName/users/?api-version=1.6" -Headers $GraphToken -Method Get | Select-Object -ExpandProperty Value).Count | Out-UDMonitorData
51 | }
52 | }
53 | New-UDColumn -Size 4 {
54 | New-UDMonitor -Title "Total Groups" -Type Line -DataPointHistory 20 -RefreshInterval 15 -ChartBackgroundColor '#5955FF90' -ChartBorderColor '#FF55FF90' @Colors -Endpoint {
55 | (Invoke-RestMethod -Uri "https://graph.windows.net/$TenantName/groups/?api-version=1.6" -Headers $GraphToken -Method Get | Select-Object -ExpandProperty Value).Count | Out-UDMonitorData
56 | }
57 | }
58 | New-UDColumn -Size 4 {
59 | New-UDGrid -Title "Users Forced to Change Password at Next Login" @Colors -Headers @("User") -Properties @("User") -AutoRefresh -RefreshInterval 20 -Endpoint {
60 | $PWUsers = Invoke-RestMethod -Uri "https://graph.windows.net/$TenantName/users/?api-version=1.6" -Headers $GraphToken -Method Get | Select-Object -ExpandProperty Value | Where-Object { $_.passwordProfile -like "*forceChangePasswordNextLogin=True*" }
61 | $UserData = @();
62 | foreach ($PWUser in $PWUsers)
63 | {
64 | $UserData += [PSCustomObject]@{ "User" = ($PWUser).displayName }
65 | }
66 | $UserData | Out-UDGridData
67 | }
68 | }
69 | }
70 | New-UDRow{
71 | New-UDColumn -Size 7{
72 | New-UdChart -Title "Licenses" -Type Bar -AutoRefresh -RefreshInterval 7 @Colors -Endpoint {
73 | $Licenses = Invoke-RestMethod -Uri "https://graph.windows.net/$TenantName/subscribedSkus/?api-version=1.6" -Headers $GraphToken -Method Get | Select-Object -ExpandProperty Value | Select-Object SkuPartNumber, ConsumedUnits -ExpandProperty PrepaidUnits | Where-Object { $_.enabled -lt 10000 }
74 | $LicenseData = @();
75 | foreach ($License in $Licenses)
76 | {
77 | $Overage = (($License).enabled) - (($License).consumedUnits)
78 | $LicenseData += [PSCustomObject]@{ "License" = ($License).skuPartNumber; "ConsumedUnits" = ($License).consumedUnits; "EnabledUnits" = ($License).enabled; "UnUsed" = $Overage }
79 | }
80 |
81 | $LicenseData | Out-UDChartData -LabelProperty "License" -Dataset @(
82 | New-UdChartDataset -DataProperty "ConsumedUnits" -Label "Assigned Licenses" -BackgroundColor "#80962F23" -HoverBackgroundColor "#80962F23"
83 | New-UdChartDataset -DataProperty "EnabledUnits" -Label "Total Licenses" -BackgroundColor "#8014558C" -HoverBackgroundColor "#8014558C"
84 | New-UDChartDataset -DataProperty "UnUsed" -Label "Un-Used Licenses" -BackgroundColor "#803AE8CE" -HoverBackgroundColor "#803AE8CE"
85 | )
86 | }
87 | }
88 | New-UDColumn -Size 4{
89 | New-UDGrid -Title "Domains" @Colors -Headers @("Domains") -Properties @("Domains") -AutoRefresh -RefreshInterval 20 -Endpoint {
90 | $Domains = Invoke-RestMethod -Uri "https://graph.windows.net/$TenantName/domains/?api-version=1.6" -Headers $GraphToken -Method Get | Select-Object -ExpandProperty Value | Where-Object { $_.name -notlike "*onmicrosoft.com*" }
91 | $Domaindata = @();
92 | foreach ($Domain in $Domains)
93 | {
94 | $DomainData += [PSCustomObject]@{ "Domains" = ($Domain).name }
95 | }
96 | $DomainData | Out-UDGridData
97 | }
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # .Description
2 | Create a live and interactive Office 365 Dashboard with PowerShell using PowerShell Universal Dashboard. You will be able to interact with your graphs/data sets
3 |
4 | 
5 |
6 | 
7 |
8 | 
9 |
10 | # .Pre-Requisites
11 | - AzureRM module
12 | - UniversalDashboard module
13 |
--------------------------------------------------------------------------------