Pester framework for Powershell testing – part 1

Today let’s talk a little bit about framework for Powershel script testing called Pester. Pester is quite fresh framework which is user friendly and very easy in implementation. I want to share with you basic example of using Pester commandlets. Let’s focus on three basic commands Describe – define name of the test group under which Context and It blocks exists. Context – define grouping of It blocks. Usually used …

Get group membership details using PowerShell

As an administrator you often need to check user group membership. Today I want to show you simple function which will help you to get that information for specific user. On the beginning of function we can check if Active Directory module is installed and validate user name: For checking user group membership we can use the following Get-ADUser commands. Unfortunately they will return just group names: Our function helps …

Kill process remotely using PowerShell function

Today’s post is about how to kill process remotely using PowerShell script. You probably had this situation when some process was consuming 99% of memory or cpu resources and server was working very slowly or was unresponsive. As a temporary solution you can kill process remotely using this function and then logon to machine and do further troubleshooting. After executing this function you will be asked to select processes from …

Adjust prompt function in PowerShell

Today I want to share with you my experience about how to adjust prompt function in PowerShell. I’ve created prompt function which display details about current user session. It shows details about followind things: – Hours – display time of last executed command – Computer name – name of the computer on which powershell session is open – User name – name of the user which is currently using Powershell …

Check firewall rules remotely using PowerShell

In past few days I had to check firewall rules setting on several machines. It was a good opportunity to write PowerShell function for this and share it with you. It’s just another simple function which will help you to gather the following firewall information from servers remotely: – Server – Direction – Action – Rule Name – Profile – Enabled – Protocol – Local Ports Below you can find …

Function to remove old VMWare snapshots

Reffering to my last article about snapshots creation, I want to show you how to remove old VMWare snapshots. Below function will remove snapshots which are older than provided number of days. To work, function requires PowerCLI module to be installed on machine from which you want execute it. NOTE: Be aware that script will remove snapshots from all VMs to which your account has access!! In result you should …

How to create your first Powershell GUI Tool

If you ever thought about creating your first PowerShell GUI tool, this article might be helpful for you. In this post you can find how to create simple tool for basic domain controller troubleshooting. At the end our tool should look like this: Below you can see how such GUI Tool is build using “System Windows Forms”. You can use it as a template for other purposes: On the beginning …

How to change SCSM connector schedule

Have you ever wonder how to change SCSM connector schedule? System Center Service Manager is relatively young product in System Center family. Functionality is not so good like in SCCM or SCOM and for some tasks we need to use Powershell. The critical functionality which is not available in SCSM GUI is adjustment of connector schedule. Todays function gives a possibility to change SCSM connector schedule which is already created. …

Get SCOM heartbeat alerts using PowerShell

Today I will show you how to get all SCOM heartbeat alerts. In this example we will gather those information from SCOM server remotely using PowerShell session. SCOM uses heartbeats to monitor communication channels between an agent and the agent’s primary management server. A heartbeat is a packet of data sent from the agent to the management server on a regular basis, by default every 60 seconds, using port 5723 …

Disable users using last logon via Powershell

Today I wanna share with you my script to disable users using last logon attribute. As an input for the script CSV file with account header is used, in which SamAccountNames are stored. For your purposes it can be adjusted to gather all users from Active Directory, but in my case I only wanted to check few accounts 🙂 Script will also ask about number of years for which users …