Export data from AzureAD using PowerShell
In this article I want to show you how Data can be exported from Azure AD using PowerShell
At first you have to connect your PowerShell with AzureAD.
To do this use the PowerShell commandlet connect-azuread
.
This should spawn a pop-up asking you for authentication.
Use Azure Credentials that have the permissions needed to at least read all properties.
If the connection worked it should look something like this
Getting the data
Here is a good reference for PowerShell commandlets related to AzureAD.
We use get-azureaddevice
to get a list of the devices in the Azure Domain.
As you can see the devices do have an ObjectID, a DeviceID and a DisplayName.
These are by far not the only Infos that are available regarding devices.
To get an overview of what values get stored for each device just take one at random (-objectid) and pipe to format list (fl).
In this case I would like to export data on the attributes DisplayName, ObjectId, ObjectType and ApproximateLastLogonTimeStamp.
These can be listed for all devices using the following command.
get-azureaddevice | select DisplayName, ObjectId, ObjectType, ApproximateLastLogonTimeStamp
Exporting the data
For better visibility you can export this info to a CSV file.
To do this pipe STDOUT to export-csv
and use a local path to store the file.
In my case the command looks like this:
get-azureaddevice | select DisplayName, ObjectId, ObjectType, ApproximateLastLogonTimeStamp | export-csv C:\temp\foo.csv
Now we can open the file, for example with excel.
Just start excel and select Data > From Text / CSV.
In the import Dialoge select comma separated import and load the file.
Using this import method you can sort columns alphabeticaly.
Cheers,
Ori
Synology NAS: Reducing the rights of domain admins
In this article i want to show you how to reduce the rights of domain admins on domain integrated synology NAS.
Why should you domain join a NAS?
The basic idea is to centralise user management.
When users and groups from AD are imported and used you can revoke a users access rights simply by deactivating his AD account.
Also you can provide read / write premissions to AD groups, and in the future only have to add users to those groups in AD.
Why would you want to revoke the rights of admin users?
It is a likley scenario that a crypto trojan or other malicious software at some point somehow gains domain admin privileges.
I have seen this a couple times.
In a case like this you do not want you NAS to be rendered useless.
Especially if you are using it to store Backups.
Problem
A Syno NAS usually get configured using the webinterface.
Here you can join it to your domain using Control Panel > Domain / LDAP > Domain.
Now you can change share permissions for users and groups imported from your domain.
To do this go to Shared Folder > Edit > Permissions and select Domain Users or Domain Groups.
However the fields "Read only" and "Custom" are grayed out for Users in the DOM\Domain-Admins group.
Solution
Go to the domain configuration again and click on Domain Options.
Here you can go to Domain Administrators and kick out the default group.
Then you can change the permissions correctly.
Dont forget to create a user for your backup solution that has write access to the share.
Cheers,
Ori
Synology NAS: Rechte von DomAdmins einschränken
In diesem Artikel möchte ich mich damit beschäftigen, wie man die Rechte von DomAdmins auf Domänenintegrierten Synology NAS einschränken kann.
Wieso sollte man eine NAS domänenintegrieren?
Der Grundgedanke dahinter ist, eine zentrale Zugriffsverwaltung zu haben.
Wenn User und Gruppen aus dem AD importiert werden, kann man im Falle eines Offboardings den Benutzeraccount deaktivieren und so die Zugänge zu allen Systemen einschränken.
Auch kann man so für AD Benutzergruppen Lese- oder Schreibrechte auf der NAS konfigurieren und muss fortan Benutzer nurnoch in diese AD Gruppe aufnehmen.
Warum sollte man DomAdmins die Rechte entziehen wollen?
Es ist durchaus denkbar, dass es ein Krypto Trojaner oder eine andere Schadsoftware schafft, sich DomAdmin Privilegien zu erschleichen.
Habe ich schon öfter gesehen.
Ihr wollt in diesem Falle sicher nicht, dass dann alles auf eurer NAS unbrauchbar ist.
Vor allem, wenn ihr dort eure Backups einlagert.
Problemstellung
Eine Syno NAS wird in der Regel über das Webinterface konfiguriert.
Hier kann die NAS dann über Control Panel > Domain / LDAP > Domain in eine Domäne aufgenommen werden.
Jetzt kann man die Zugriffsrechte auf Freigaben für Benutzer oder Gruppen aus der Domäne anpassen.
Hierzu geht man auf Shared Folder > Edit > Permissions und wählt Domain Users oder Domain Groups.
Allerdings sind die Felder Read only und Custom für Benutzer in der Gruppe DOM\Domänen-Administratoren ausgegraut.
Lösung
Geht nochmal in der Domänen Konfiguration auf den Reiter Domain und klickt auf Domain Options.
Hier könnt ihr dann unter Domain Administrators die Gruppe aus dem herausnehmen, was die NAS unter "Domain Administrators" führt.
Dann können die Rechte auch angepasst werden.
Richtet eurer Backup Lösung jetzt noch einen dedizierten User ein und gebt diesem Schreibrechte auf dem Share.
Cheers,
Ori
Troubleshooting of windows server hard disk extensions / ESXi
This article desribes how to handle issues you can run into when extending windows server hard disks on ESXi.
In this perticular case the C:\ Partition should be extended from 139GB to 156GB.
After the extending the disk the C:\ Partition to 156GB the Explorer and Monitoring still show that the volume size is 139GB.
Troubleshooting
Always check that there is enaugh disk space remaining on the storage.
If a full storage is not the cause of this issue, keep looking.
A reboot always is a good idea, however in a production envoirement that is not always possible and does not help in this case.
A good trick is to extend the harddrive for one more GB.
After a refresh of the disk management utility using F5 there should be 1GB that is showing as "unallocated".
After extending the volume again, issues like this are normally solved.
Do not wonder that the harddrive is showing as 156GB angezeigt wird...
... this is Windows, and there is a 100MB reserved partition in front of C:\ and the explorer only counts full GB.
Cheers,
Ori
Extend hard disk windows server / ESXi
In this article i will show how to extend the hard disk of a virtual windows server on a ESXi (VMware) hypervisor.
The task is relativley trivial but has to be performed every once in a while so I thought why not write a short article on it.
How to
At first take a look at what you want to extend.
In this case it is the E:\ drive of a windows server 2016.
Before changing anything we need to check that the host has enough resources available.
Start, depending on the ESXi version, the vSphere console or a browser and connect to the ESXi Hypervisor or the vCenter.
Open the VM settings and check on what storage the virtual harddrive (the .vdk or .vmdk file) is located on.
In this case the Storage is called "Datastore-VM".
After that hightlight the hypervisor on the left hand and check how much free space there is left on the storage.
Since there is still over 6TB left, extending the harddrive for 60GB should not be a problem.
Now change the size of the harddrive in the settings of the virtual machine.
When you check the harddrive in the explorer it appears to still have the same size.
The reason for this is that we still need to extend the volume on this harddrive.
Start the Diskmanagement using windows + r -> diskmgmt.msc
Rightklick the E:\ Volume and select "Expand volume..."
After you have gone trough the wizard your job should be done.
Cheers,
Ori
Troubleshooting von Laufwerkserweiterung Windows Server / ESXi
In diesem Artikel soll es darum gehen, wie man mit Problemen umgehen kann, die beim Erweitern von Windows Server Festplatten auf ESXi Hosts auftreten können.
In diesem speziellen Fall sollte die C:\ Partition von 139GB auf 156GB erweitert werden.
Nach dem Erweitern über die Datenträgerverwaltung wird die C:\ Partition im Explorer (und Monitoring weiterhin mit 139GB angezeigt.
Troubleshooting
Zuerst immer den Speicher prüfen, auf dem die VM liegt.
Wenn der Speicher eine Erweiterung dieser Größenordnung zulässt, müssen wir woanders suchen.
Prinzipiell lohnt ein Reboot, ist aber im Produktivbetrieb meist nicht möglich und verschafft in diesem Falle auch keine Abhilfe.
Ein guter Trick ist es, die Festplatte um einen weiteren Gigabyte zu erweitern
Nach einem Refresh der Datenträgerverwaltung über F5 sollte 1GB als "nicht zugeordnet" angezeigt werden.
Nach einem erneuten Erweitern des Volumes sind Probleme dieser Art dann meistens behoben.
Wundert euch auch nicht, dass die Festplatte im Explorer nur mit 156GB angezeigt wird...
... ist halt Windows, da hängt noch eine 100MB Partition vorne an C:\ und es werden nur volle GB im Explorer gezählt.
Cheers,
Ori
Daten per Powershell aus AzureAD exportieren
In diesem Artikel soll es darum gehen, wie ihr euch mit der Powershell Daten aus Azure ziehen könnt.
Als erstes müsst Ihr eure Powershell mit einem AzureAD verbinden.
Hierzu gebt ihr in der Powershell den Befehl connect-azuread
ein.
Jetzt sollte ein pop-up erscheinen, bei dem ihr euch mit einem Account authentifizieren müsst, der Zugriff auf das AzureAD hat.
Anschließend solltet ihr folgende Zeile sehen.
Daten abrufen
Diese Microsoft Seite gibt eine gute Übersicht, welche Commandlets die Powershell bezüglich AzureAD mitbringt.
Wir verwenden get-azureaddevice
um eine Liste der Geräte in der Domäne zu erhalten.
Wie ihr seht, haben die Geräte eine ObjectID, eine DeviceID und einen DisplayName.
Das sind aber nicht alle Informationen, die über ein Gerät zur Verfugung stehen.
Wenn wir uns ein zufälliges gerät nehmen (-objectid) und nach format list (fl) pipen, erhalten wir eine Übersicht über alle Werte die über das Gerät gespeichert werden.
Ich interessiere mich in diesem Beispiel für die Attribute DisplayName, ObjectId, ObjectType und ApproximateLastLogonTimeStamp.
Diese können wir uns jetzt listen lassen.
get-azureaddevice | select DisplayName, ObjectId, ObjectType, ApproximateLastLogonTimeStamp
Daten exportieren
Es empfiehlt sich der besseren Übersicht halber diese Daten in eine CSV Datei zu exportieren.
Hierzu pipen wir STDOUT nach export-csv
und geben einen lokalen Speicherpfad an.
In unserem beispiel sieht das so aus:
get-azureaddevice | select DisplayName, ObjectId, ObjectType, ApproximateLastLogonTimeStamp | export-csv C:\temp\foo.csv
Jetzt können wir die Datei z.b. mit Excel öffnen.
Hierzu einfach Excel starten und über Daten > Aus Text / CSV wählen.
In dem anschließend erscheinenden Dialog wählt ihr einen kommaseparierten Import und klickt auf Laden.
So lassen sich die Spalten beispielsweise alphabetisch sortieren.
Cheers,
Ori
Festplatte erweitern Windows Server / ESXi
In diesem Artikel geht es darum wie man bei einem mit ESXi (VMware) virtualisierten Windows Server eine Festplatte vergrößern kann.
Der Task ist eigentlich relativ trivial, fällt aber immer mal wieder an.
Ich dachte daher ich schreibe dazu mal einen kurzen Artikel.
Umsetzung
Als erstes sollten geprüft werden welches Festplatte erweitert werden soll.
In diesem Beispiel Laufwerk E:\ auf einem Windows Server 2016
Bevor wir irgendwas anfassen müssen wir überprüfen, dass der Host genug ressourcen zur Verfügung hat.
Wir starten also, abhängig von der ESXi Version, die vSphere Verwaltungskonsole oder einen Browser und verbinden uns zu dem ESXi Hypervisor oder dem vCenter.
Hier öffnen wir die Eigenschaften der VM und überprüfen wo sich die virtuelle Festplatte vom Typ .vdk oder .vmdk befindet.
Wählt die Festplatte aus die ihr erweitern wollt und schaut auf welchem Storage die Festplatte sich befindet.
In diesem Fall ist es "Datastore-VM".
Danach wählt Ihr links den Hypervisor aus und schaut euch im Reiter Übersicht bei Ressourcen an, dass noch genug Speicherplatz zur Verfügung steht.
Da auf dem Storage noch über 6TB frei sind, sollten 60GB mehr kein Problem sein.
Passt jetzt in den Einstellungen der VM die Größe der virtuellen Festplatte an.
Wenn ihr euch jetzt anmeldet, werdet ihr festellen, dass die zweite Festplatte im Explorer noch mit der selben Größe angezeigt wird.
Das liegt daran, dass wir das Volume auf der Festplatte noch vergrößern müssen.
Startet dazu die Dateiträgerverwaltung mit Windows + R -> diskmgmt.msc
Hier macht ihr einen Rechtsklick auf das zu erweiternde Volume und wählt "Volume erweitern..."
Nachdem Ihr den Dialog durchgeklickt habt sollte das Laufwerk E:\ 120GB messen.
Cheers,
Ori
Changing the DSRM password
When setting up an active direcotry domain you will be asked to set a DSRM password.
DSRM stands for Directory Services Restore Mode and is a backdoor into the database if everything else fails.
When an admin is changing the company, part of the process should be to change administrative passwords.
The DSRM password however is somthing people often forget about so it remains unchanged.
This is why I want to take a second to show you how to change it.
Changing the Password
First you start an administrative CMD on a Domain Controller.
Start the tool ntdsutil
and typeset dsrm password
.
Now we need do decide on wich DC the password should be changed and choose a new one.
reset password on server null
Cheers,
Ori
Das DSRM Passwort zurücksetzen
Bei der Einrichtung einer Active Directory Domänenumgebung wird ein sogenanntes DSRM Passwort gesetzt.
DSRM steht für Directory Services Restore Mode oder zu Deutsch "Verzeichnisdienst-Wiederherstellungs-Modus".
Er stellt quasi eine backdoor bereit mit der man sich Zugang zum AD verschaffen kann wenn alle Stricke reißen.
Falls mal ein Admin das Unternehmen wechselt, sollte ein Teil dieses Prozesses sein, die administrativen Passwörter zu ändern.
Das DSRM Passwort wird dabei gerne mal vergessen und daher möchte ich hier kurz zeigen, wie Ihr das Passwort ändern könnt.
Passwort Zurücksetzen
Als Erstes startet Ihr auf einem Domain Controller eine administrative CMD.
Startet das Tool ntdsutil
und gebtset dsrm password
ein.
Jetzt müssen wir noch entscheiden auf welchem DC das Passwort angepasst werden soll und vergeben ein Neues.
reset password on server null
Cheers,
Ori