Author Archives: Michael Miklis

PowerShell Windows

Safely change the Administrator Password

In one of my current projects, the customer wants to change the password of the Active Directory built-in Administrator account. This account was used several years for setting up tasks, running services and all kinds of things. To ensure that all major business applications will not be affected by that change, we needed to identify all processes and persons using the Administrator account and create separate service accounts for these applications.

Read More
NetAtmo Programming

Netatmo Weather Station Shell Script

I got a lot of feedback for my blog post Read NetAtmo weather station data via Script and Export NetAtmo weather station data to CSV / Excel. A lot of people seem to be interested by using the data from thier Netatmo weather station.

Bernd G. – one of my blog readers, extended my scripts and build a complete Linux shell wrapper around it. That makes it much easier and adds more flexibility to the scripts. Bernd allowed me to post his script on my blog to share it.

Read More
PowerShell Programming Windows

Change DNS settings on multiple Windows Servers and Workstations

During several Active Directory migration projects I needed to change the DNS server IP addresses on several computers if the DNS service was installed on the Active Directory Domain Controller. Therefore I wrote a little PowerShell script to connect to remote computer and change the DNS server IP address in the network connection via WMI to the onces specified in the script.

This makes changing the IP address of a DNS server much easier because all Windows systems based on Windows Server 2008 / Vista or newer can be edited by using this PowerShell script.

Read More
Bechtle-Blog PowerShell Windows

Using Windows certificate store in Mozilla Firefox

Lots of companies are using Mozilla Firefox in their corporate environment. Firefox came up with a great new feature in the latest version – it will support Windows enterprise trusted root certificates! No more need for adding certificates to Firefox seperatly using the keytool:

firefox-connection-not-secure

Just use the Windows Active Directory Group Policies to deploy your certificates – most of you already do this for use with Microsoft Internet Explorer and other software. To enable this great new feature Firefox introduced a new configuration parameter named security.enterprise_roots.enabled this needs to be set to true in the about:config page:

Read More
Bechtle-Blog Office 365 PowerShell

Assign Office 365 licenses based on Active Directory groups

I’ve done several Microsoft Office 365 project with together with some of our customers. In most implementations I was asked if there’s a way to assign Office 365 licenses (a.k.a. plans) to users based on their Active Directory group memberships.

Most companies have built their entire permission model on Microsoft Active Directory. With Active Directory Federation Services (ADFS) Microsoft offers a powerful and great tool for synchronizing user and group account from the customers on-premise environment into the Office 365 cloud.

Unfortunately there is no built-in technique to automatically assign licenses. Therefore I wrote a small PowerShell script to complete this task.

Read More
Programming Synology

Edit Synology Photo Station Album Permissions via Script

I’m using Synology Photo Station for storing all my pictures and share access to all family members. Being an IT-Guy I’m very concerned about security and especially the access rights to all albums. Unfortunately, Synology marks a new album always as public. Instructing my family to set the correct album permissions didn’t work because they’re normal users and they don’t want to do any settings for albums. They just want to access and upload their photos.

Synology Photo Station Permissions

At this point, I decided to have a look on the Postgres SQL Database that is being used

Read More
PowerShell Programming

Update environment variables in current process

Currently, I’m involved in a huge PowerShell based deployment project for one of our major customers. The whole deployment process including several WPF-based GUIs are written in PowerShell. This week we had a new issue to fix regarding environment variables. First of all some background knowledge about environment variables in Windows.

Environment Variables are stored inside the registry and each process will read them from the registry and store the variables in its own environment. Each new process (called sub-process) that will be started from another process will inherit the environment variables from its parent process.
The problem will be if the parent process starts several sub-processes and each of them will subsequently change / expand environment variables like the %PATH% variable. Sub-Process #2 is not aware of the changes Sub-Process #1 made to the environment variables.

To work around this issue, I wrote a small PowerShell function which utilizes .NET Framework Methods to re-read the environment variables and store them for the current process:

#####################################################################
##
## (C) 2015 Michael Miklis (michaelmiklis.de)
##
##
## Filename:      Update-Environment.ps1
##
## Version:       1.0
##
## Release:       Final
##
## Requirements:  -none-
##
## Description:   Refresh the current environment variables
##
## 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 Update-Environment {
    <#
    .SYNOPSIS
    Refresh all environment variables

    .DESCRIPTION
    Reads all environement variables from registry for scope user and machine
    and updates the current process environment variables
        
    .EXAMPLE
    Update-Environment
    #>


    # first update the environment variables from the machine scope
    $ENV_MACHINE = ([Environment]::GetEnvironmentVariables('Machine'))
    foreach ($EnvVar in $ENV_MACHINE.keys) {
        Set-Item "Env:$($EnvVar)" -Value $ENV_MACHINE[$EnvVar]
    }

    # second update the environment variables from the user scope
    $ENV_USER = ([Environment]::GetEnvironmentVariables('User'))
    foreach ($EnvVar in $ENV_USER.keys) {
        Set-Item "Env:$($EnvVar)" -Value $ENV_USER[$EnvVar]
    }

    # now Update the Path variable (path variable gets
    # combined by User:Path and Machine:Path
    # User:Path has precedence over Machine:Path
    if ($ENV_USER.ContainsKey('Path')) {
        Set-Item env:Path -Value ((($ENV_USER.Path -split ";") + ($ENV_MACHINE.Path -split ";") | select -Unique) -join ";")
    }

}

#_____________________________________________________________________________________________

#call Update-Environment() function
Update-Environment

We’ve added the function to our framework – this will be the first function that we’re calling after every external process (Start-Process), we’ve started.

Read More
Mac OS X Programming

Evernote Backup using Apple Script

Today I’ve created a small Apple Script to export all my Evernote notes into a folder and compress the notes to a tar.gz archive for storing on my NAS. Feel free to use this script and customize for your own environment.

[UPDATE] Fixed an issued causing the export to fail if empty notebooks are present. Thanks to Darryl for the solution in the comments.

Read More
PowerShell

Set Creation- and Modification-Date from Filename

After my return of my last vacation, I had a bunch of videos that I wanted to edit, transcode and archive. First I renamed the files based on their creation date so that this information is being preserved and consistent during the whole process.
When my editing and transcoding was done I just needed to set the file’s modification and creation date back to when it was originally taken. To do this job I created a small PowerShell Script I want to share with you:

$Directory = "C:PathtoFiles"
$DateFormat = "yyyy-MM-dd_HHmmss"


foreach ($file in (Get-ChildItem $Directory)) {
    $date_from_file=[datetime]::ParseExact($file.Name.Substring(0,$file.Name.Length-4), $DateFormat, $null)

    $file.CreationTime = $date_from_file
    $file.LastAccessTime = $date_from_file
    $file.LastWriteTime = $date_from_file

    Write-Host ($file.Name + " - " + $date_from_file)
}

Here’s the result – the date / timestamp in the filename is identical with the actual file date:

Set Creation- and Modification-Date from Filename

Read More
NetAtmo Programming

Read NetAtmo weather station data via Script

Based on the feedback for my previous blog post Export NetAtmo weather station data to CSV / Excel I created a small script to get the module, device ID, temperature, humidity and also all sensor data from your NetAtmo weather station and modules.

NetAtmo_JSON_JQ

This scripts also uses curl to login to the web page and then download the device data using the NetAtmo Web API. This script will return all the information in JSON format.

Read More
1 2 3 5