Functions/Get-MSOnlineSettingObjects.ps1

<#
.SYNOPSIS
    This function returns objects representing the various settings which can be retrieved from Microsoft Online.
.DESCRIPTION
    This function returns objects representing the various settings which can be retrieved from Microsoft Online.
    Each object contains a description of the setting, a script block which returns the value of the setting, and the name of the setting which is suitable for a variable name.
#>

function Get-MSOnlineSettingObjects {
    [CmdletBinding(PositionalBinding=$false)]
    [OutputType([PSCustomObject[]])]
    param ()

    # Return the setting objects
    return @(
        [PSCustomObject]@{
            Description = "account SKUs"
            ScriptBlock = {
                Get-MsolAccountSku
            }
            VariableName = "AccountSkus"
        },
        [PSCustomObject]@{
            Description = "administrative units"
            ScriptBlock = {
                Get-MsolAdministrativeUnit
            }
            VariableName = "AdministrativeUnits"
        },
        [PSCustomObject]@{
            Description = "administrative unit members"
            ScriptBlock = {
                foreach ($unit in (Get-MsolAdministrativeUnit)) {
                    foreach ($member in (Get-MsolAdministrativeUnitMember -AdministrativeUnitObjectId $unit.ObjectId)) {
                        $member | Add-Member -NotePropertyName "AdministrativeUnitDisplayName" -NotePropertyValue $unit.DisplayName
                        $member | Add-Member -NotePropertyName "AdministrativeUnitDisplayObjectID" -NotePropertyValue $unit.ObjectID
                        $member
                    }
                }
            }
            VariableName = "AdministrativeUnitMembers"
        },
        [PSCustomObject]@{
            Description = "company allowed data locations"
            ScriptBlock = {
                Get-MsolCompanyAllowedDataLocation
            }
            VariableName = "CompanyAllowedDataLocations"
        },
        [PSCustomObject]@{
            Description = "company information"
            ScriptBlock = {
                Get-MsolCompanyInformation
            }
            VariableName = "CompanyInformation"
        },
        [PSCustomObject]@{
            Description = "device registration service policies"
            ScriptBlock = {
                Get-MsolDeviceRegistrationServicePolicy
            }
            VariableName = "DeviceRegistrationServicePoliciesCsv"
        },
        [PSCustomObject]@{
            Description = "DirSync features"
            ScriptBlock = {
                Get-MsolDirSyncFeatures
            }
            VariableName = "DirSyncFeatures"
        },
        [PSCustomObject]@{
            Description = "domains"
            ScriptBlock = {
                Get-Domain
            }
            VariableName = "Domains"
        },
        [PSCustomObject]@{
            Description = "domain federation settings"
            ScriptBlock = {
                foreach ($domain in (Get-MsolDomain)) {
                    if ($domain.Authentication -eq "Federated") {
                        Get-MsolDomainFederationSettings -DomainName $domain.Name
                    }
                }
            }
            VariableName = "DomainFederationSettings"
        },
        [PSCustomObject]@{
            Description = "roles"
            ScriptBlock = {
                Get-MsolRole
            }
            VariableName = "Roles"
        },
        [PSCustomObject]@{
            Description = "role members"
            ScriptBlock = {
                foreach ($role in (Get-MsolRole)) {
                    foreach ($member in (Get-MsolRoleMember -RoleObjectId $role.ObjectID)) {
                        $member | Add-Member -NotePropertyName "RoleName" $role.Name
                        $member
                    }
                }
            }
            VariableName = "RoleMembers"
        },
        [PSCustomObject]@{
            Description = "scoped role members"
            ScriptBlock = {
                foreach ($role in (Get-MsolRole)) {
                    foreach ($unit in (Get-MsolAdministrativeUnit)) {
                        foreach ($member in (Get-MsolScopedRoleMember -RoleObjectId $role.ObjectId -AdministrativeUnitObjectId $unit.ObjectID)) {
                            $member | Add-Member -NotePropertyName "ScopedAdministrativeUnitId" -NotePropertyValue $unit.ObjectID
                            $member | Add-Member -NotePropertyName "ScopedAdministrativeUnitDisplayName" -NotePropertyValue $unit.DisplayName
                            $member | Add-Member -NotePropertyName "ScopedRoleName" -NotePropertyValue $role.Name
                            $member
                        }
                    }
                }
            }
            VariableName = "ScopedRoleMembers"
        },
        [PSCustomObject]@{
            Description = "service principals"
            ScriptBlock = {
                foreach ($principal in (Get-MsolServicePrincipal)) {
                    $tempObject = $principal | Select-Object *
                    $tempObject.Addresses = $tempObject.Addresses.Address
                    $tempObject
                }
            }
            VariableName = "ServicePrincipals"
        },
        [PSCustomObject]@{
            Description = "subscriptions"
            ScriptBlock = {
                Get-MsolSubscription
            }
            VariableName = "Subscriptions"
        }
    )
}