PowerShell one-liner: Get AD user groups

Starting from today we will add new series of articles describing one-liner scripts. In this post I would like to show you how to get group names that user is a member of using just one-liner script. Get-ADUser allows you to list all information for Active Directory user account. This command is a part of ActiveDirectory module where you can also see other commands. Check available modules on your PC: …

How to create Azure Automation runbook

Today I will not show you any script, but will guide you how to create Azure Automation runbook. For those who didn’t heard about Azure Automation I strongly recommend to check Microsoft documentation – link. To make long story short – Azure Automation is the service in Azure cloud, which allow to automate repetitive tasks in your environment using Powershell :). Not only standard work which can be done on …

Get date remotely and convert it to different time zone

Today I thought I would share a one of my PowerShell function that I wrote for converting time zones from remote servers. If you have large scale environment you are probably dealing with several different time zones on your machines. To get date in different zone you can use below function. Usage: Output: In this function I’ve just added most common time zones: UTC – Coordinated Universal Time IST – …

Test LDAP Connection with PowerShell

In this article you will find out how to test LDAP Connection to your domain controllers. It is very similar to previous post about Test-PortConnection function. In this example we will focus on making an LDAP connection using ADSI. On the beginning of function we need to check if DC name provided as a parameter is valid: Usage: Final script:

Test connection to servers on several ports

Below you can find simple function to test connection on several ports. Sometimes you had to check connectivity in your environment to all servers. This script will make it easy for you. Script use Test-NetConnection command which allows to specify port number for checking: For more information about this command please refer to technet site. Usage: Output: Final script:

How to reset Azure AD MFA settings

Today I want to show you how to easly reset Azure AD MFA settings. In big organization is very frequent situation that users want to change their authentication method or phone number. To make life easier I’ve prepared script which will reset Multi Factor Authentication settings for specific UserPrincipalName. As input parameters to function two variables should be provided – Credentials – PSCredential object (eg. gathered from Get-Credentail function) – …

Scan event log to find if service was installed in the system

I recently had to scan system event log on all production servers to find out which services have been installed. In this article I will describe how to scan your infrastracture for this specific event. For selecting servers I used Out-GridView command: Please note that in Foreach loop you need to provide name for servers column in CSV file – in my case it was “Server name”: We have to …

ADSI – Searching for an user object in Active Directory

In this article you will learn how to use ADSI searcher. Script finds users based on samaccountnames and gathers their attributes. Instead of using AD cmdlets like Get-ADUser we can use ADSI search method which is much faster – it can be used when we have to query many users: In $SAMNames variable you have to add your AD users samaccountnames and in object part you can specify which attributes …

Get ADFS relying parties signing certificates

Today I want to show you how to check relying party signing certificates. If you working in large scale ADFS environment where you have huge amount of relying parties it might be difficult to check lots of thing manually. This is why you are forced to use ADFS cmdlets available on microsoft pages – link. In this article you will find out how to check signing certificates using PowerShell function. …

Check counters values remotely using PowerShell

Today you will find out how to get counters details remotely from servers. Function is useful to check quickly if some specific counter values increased or was it just a temporary spike. Function is based on a Get-Counter command: For more information about Get-Counter you can visit MS site – link. In this function I added just basic counters: – Memory – Processor – PhysicalDisk – Network Interface Number of …