diff --git a/ITGlue/Office365Sync/single.ps1 b/ITGlue/Office365Sync/single.ps1
index 234c554..a61d292 100644
--- a/ITGlue/Office365Sync/single.ps1
+++ b/ITGlue/Office365Sync/single.ps1
@@ -48,8 +48,11 @@ function Build365TenantAsset ($tenantInfo) {
"tenant-id" = $tenantInfo.TenantID
"initial-domain" = $tenantInfo.InitialDomain
"verified-domains" = $tenantInfo.Domains
+ "admins" = $tenantInfo.Admins
+<# Removed due to ITGlue Native Office 365 Integration
"licenses" = $tenantInfo.Licenses
"licensed-users" = $tenantInfo.LicensedUsers
+#>
}
}
}
@@ -66,61 +69,78 @@ $customers = Get-MsolPartnerContract -All
$365domains = @()
foreach ($customer in $customers) {
+ # Null the variables for each customer
+ $companyInfo = $null
+ $CompanyAdminRole = $null
+ $RoleID = $null
+ $customerDomains = $null
+ $initialDomain = $null
+
+ $domainTableTop = $null
+ $domainTableBottom = $null
+ $domainCol1 = $null
+ $domainString = $null
+ $domaintable = $null
+
+ $admins = $null
+ $adminsTableTop = $null
+ $adminsTableBottom = $null
+ $adminsCol1 = $null
+ $adminString = $null
+ $admintable = $null
+
Write-Host "Getting domains for $($customer.name)" -ForegroundColor Green
$companyInfo = Get-MsolCompanyInformation -TenantId $customer.TenantId
+ #Get Admins
+ $RoleName = "Company Administrator"
+ $CompanyAdminRole = Get-MsolRole | Where-Object{$_.Name -match $RoleName}
+ $RoleID = $CompanyAdminRole.ObjectID
+ $Admins = Get-MsolRoleMember -TenantId $Customer.TenantId -RoleObjectId $RoleID
+
$customerDomains = Get-MsolDomain -TenantId $customer.TenantId | Where-Object {$_.status -contains "Verified"}
$initialDomain = $customerDomains | Where-Object {$_.isInitial}
- $Licenses = $null
- $licenseTable = $null
- $Licenses = Get-MsolAccountSku -TenantId $customer.TenantId
- if ($licenses) {
- $licenseTableTop = "
| License Name | Active | Consumed | Unused |
|---|
| "
- $licenseTableBottom = " |
"
- $licensesColl = @()
- foreach ($license in $licenses) {
- $licenseString = "$($license.SkuPartNumber)$($license.ActiveUnits) active | $($license.ConsumedUnits) consumed | $($license.ActiveUnits - $license.ConsumedUnits) unused"
- $licensesColl += $licenseString
+
+ if ($customerDomains) {
+ $customerDomains = $customerDomains | Sort-Object -Property @{Expression = {$_.IsDefault}; Ascending = $false}, Name
+ $domainTableTop = "
| Domain Name | IsDefault | Status | Authentication |
|---|
| "
+ $domainTableBottom = " | "
+ $domainCol1 = @()
+ foreach ($custdomain in $customerDomains) {
+ $domainString = "$($custdomain.Name) | $($custdomain.IsDefault) | $($custdomain.Status) | $($custdomain.Authentication)"
+ $domainCol1 += $domainString
}
- if ($licensesColl) {
- $licenseString = $licensesColl -join " | | "
+ if ($domainCol1) {
+ $domainString = $domainCol1 -join " |
"
}
- $licenseTable = "{0}{1}{2}" -f $licenseTableTop, $licenseString, $licenseTableBottom
+ $domaintable = "{0}{1}{2}" -f $domainTableTop, $domainString, $domainTableBottom
}
- $licensedUserTable = $null
- $licensedUsers = $null
- $licensedUsers = get-msoluser -TenantId $customer.TenantId -All | Where-Object {$_.islicensed} | Sort-Object UserPrincipalName
- if ($licensedUsers) {
- $licensedUsersTableTop = "
| Display Name | Addresses | Assigned Licenses |
|---|
| "
- $licensedUsersTableBottom = " | "
- $licensedUserColl = @()
- foreach ($user in $licensedUsers) {
-
- $aliases = (($user.ProxyAddresses | Where-Object {$_ -cnotmatch "SMTP" -and $_ -notmatch ".onmicrosoft.com"}) -replace "SMTP:", " ") -join " "
- $licensedUserString = "$($user.DisplayName) | $($user.UserPrincipalName) $aliases | $(($user.Licenses.accountsku.skupartnumber) -join " ")"
- $licensedUserColl += $licensedUserString
+
+ if ($Admins) {
+ $adminsTableTop = "
| Display Name | EmailAddeess | isLicensed |
|---|
| "
+ $adminsTableBottom = " | "
+ $adminsCol1 = @()
+ foreach ($admin in $admins) {
+ $adminString = "$($admin.DisplayName) | $($admin.EmailAddress) | $($admin.IsLicensed)"
+ $adminsCol1 += $adminString
}
- if ($licensedUserColl) {
- $licensedUserString = $licensedUserColl -join " |
| "
+ if ($adminsCol1) {
+ $adminString = $adminsCol1 -join " |
| "
}
- $licensedUserTable = "{0}{1}{2}" -f $licensedUsersTableTop, $licensedUserString, $licensedUsersTableBottom
-
-
+ $admintable = "{0}{1}{2}" -f $adminsTableTop, $adminString, $adminsTableBottom
}
-
-
+
$hash = [ordered]@{
TenantName = $companyInfo.displayname
PartnerTenantName = $customer.name
Domains = $customerDomains.name
+ DomainTable = $domaintable
TenantId = $customer.TenantId
InitialDomain = $initialDomain.name
- Licenses = $licenseTable
- LicensedUsers = $licensedUserTable
+ Admins = $admintable
}
$object = New-Object psobject -Property $hash
$365domains += $object
-
}
# Get all organisations
@@ -149,12 +169,11 @@ foreach ($365tenant in $365domains) {
$hash = [ordered]@{
Key = "$($365tenant.TenantId)-$($match.OrganizationID)"
TenantName = $365tenant.TenantName
- Domains = ($365tenant.domains -join ", ")
+ Domains = $365tenant.DomainTable
TenantId = $365tenant.TenantId
InitialDomain = $365tenant.InitialDomain
+ Admins = $365tenant.Admins
OrganizationID = $match.OrganizationID
- Licenses = $365tenant.Licenses
- LicensedUsers = $365tenant.LicensedUsers
}
$object = New-Object psobject -Property $hash
$allMatches += $object
@@ -179,4 +198,4 @@ foreach ($match in $uniqueMatches) {
$newBody = Build365TenantAsset -tenantInfo $match
$newItem = CreateITGItem -resource flexible_assets -body $newBody
}
-}
\ No newline at end of file
+}
|