Tag Archives: GitHub

Docker Programming

RPi-Monitor Docker container

I’ve been using RPI-Monitor from RPi-Experiences several years on all my Raspberry Pis. I think it is a great Web-UI to get a quick view of the overall system state of your Raspberry Pi:

On my way to put most of my Linux / RPi services into individual docker containers, I came across my RPi-Monitor installation. There were several images available on Docker Hub but they had either no DOCKERFILE published or they did not use the values and metrics from the actual docker host.

Read More
Docker Smart Home

ha-bridge in Docker container on a Raspberry Pi

During Christmas holidays I spent some time to work with Docker and migrate all my smart home components and services into separate Docker containers. During that process, I decided to use a Raspberry PI 3 as my Docker host.

To connect my smart home system with Amazon Alex I use habridge from bwssystems. Unfortunately, there was no official Docker Image on Docker Hub. Therefore I created a Dockerfile and created a new Github Repository and a Docker Hub Repository:

https://github.com/michaelmiklis/docker-rpi-habridge
https://hub.docker.com/r/michaelmiklis/rpi-habridge

The Dockerfile is based on the great work from tsgoff: https://github.com/tsgoff/docker-alexa-ha-bridge

Most of my Docker containers are based on the resin.io base-images. These guys are doing a great job in maintaining their images.

Read More
Bechtle-Blog Office 365 PowerShell

Update: Assign Office 365 licenses based on Active Directory groups (version 1.1)

Several months ago, I published a PowerShell script to assign Office 365 licenses to user accounts based on their on-premises Active Directory group memberships (original post). I received a lot of great feedback for that script and added some bugfixes and support for multiple assigned licenses. Multiple assigned licenses will occur if your users are using multiple Office 365 services, like Intunes and Office 365 E3, or maybe Windows E3 for instance.

Like all my new coding project you’ll also find the PowerShell script on GitHub:
https://github.com/michaelmiklis/Set-MSOLLicenseToADGroupMembers.ps1

You just need to modify the on the end to match your environment (username, password, group names, e.g.):

######################################################################
## (C) 2017 Michael Miklis (michaelmiklis.de)
##
##
## Filename:      Set-MSOLLicenseToADGroupMembers.ps1
##
## Version:       1.1
##
## Release:       Final
##
## Requirements:  -none-
##
## Description:   Assign Office 365 Licenses based on Active Directory
##                Groups.
##
## This script is provided 'AS-IS'.  The author does not provide
## any guarantee or warranty, stated or implied.  Use at your own
## risk. You are free to reproduce, copy & modify the code, but
## please give the author credit.
##
####################################################################
Set-PSDebug -Strict
Set-StrictMode -Version latest
  
 
function Set-MSOLLicenseToADGroupMembers {
    <#
    .SYNOPSIS
    Assigns Office 365 Licenses to Members of AD-Group
  
    .DESCRIPTION
    The Set-MSOLLicenseToADGroupMembers CMDlet gets all users from a
    specified AD-Group and assigns a specified Office 365 License to
    the corresponding Office 365 identities
  
    .PARAMETER GroupName
    Name of the Active Group
  
    .PARAMETER License
    Name of the License
 
    .PARAMETER UsageLocation
    Name of the Location
  
    .EXAMPLE
    Set-MSOLLicenseToADGroupMembers -GroupName "Office365_E3" -License "contoso:ENTERPRISEPACK"
 
    #>
      
    param (
        [parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]$GroupName,
        [parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]$License,
        [parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]$LicenseName,
        [parameter(Mandatory=$false)]
        [ValidateNotNullOrEmpty()]$UsageLocation="DE"
    )
 
    foreach ($User in (Get-ADGroupMember -Identity $GroupName)) {
    $User = Get-ADUser -Identity $User -Properties UserPrincipalName
    $MsOlUser =  Get-MsolUser -UserPrincipalName $User.UserPrincipalName -ErrorAction SilentlyContinue 
 
    $UserLicensePresent = $false

    if ($MsOlUser -ne $null) {
        Write-Host ("Found Office 365 User: " + $MsOlUser.UserPrincipalName)
            Set-MsolUser -UserPrincipalName $User.UserPrincipalName -UsageLocation $UsageLocation
 
        if ($MSOlUser.IsLicensed -eq $false) {
            Write-Host ("User not licensed - assigning license: " + $LicenseName)

            Set-MSOLUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses $LicenseName
            Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -LicenseOptions $License
        }
        else {
            foreach ($UserLicense in $MSOLUser.Licenses)
            {
                if ($UserLicense.AccountSkuId -eq $LicenseName)
                {
                    $UserLicensePresent = $true
                    break
                }
            }


            if ($UserLicensePresent -eq $false) {
                Write-Host ("User licensed, but not with correct license - assigning license: " + $LicenseName)

                Set-MSOLUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses $LicenseName
                Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -LicenseOptions $License
            }
            else {
                Write-Host ("User has already a correct license assigned: " + $LicenseName)
            }
        }
    }
    }
 
}
 
Import-Module MSOnline
 
$Username = "xxxxx"
$Password = "xxxxx"
 
# Convert the plain text password to a secure string
$SecurePassword=ConvertTo-SecureString –String $Password –AsPlainText –force
$Credential=New-object System.Management.Automation.PSCredential $Username,$SecurePassword
 
# Create new Office 365 license options
$LicenseOfficeProPlus = New-MsolLicenseOptions -AccountSkuId "SUBSCRIPTION_NAME:OFFICESUBSCRIPTION"
$LicenseE3withoutExchange = New-MsolLicenseOptions -AccountSkuId "SUBSCRIPTION_NAME:ENTERPRISEPACK" -DisabledPlans "EXCHANGE_S_ENTERPRISE"
 
# Connect to Microsoft Office 365 tenant
Connect-MsolService -Credential $credential
 
# Assign licenses based on Active Directory group membership
Set-MSOLLicenseToADGroupMembers -GroupName "O365_PROPLUS" -License $LicenseOfficeProPlus -LicenseName "SUBSCRIPTION_NAME:OFFICESUBSCRIPTION" -UsageLocation "DE"
Set-MSOLLicenseToADGroupMembers -GroupName "O365_E3" -License $LicenseE3withoutExchange -LicenseName "SUBSCRIPTION_NAME:ENTERPRISEPACK" -UsageLocation "DE"
Read More