get-date

PowerShell Tip of the Week: Get name of a month and number of days

Recently I was working on a new report for entire environment. I had to calculate servers total uptime and downtime in previous month. I prepared script for that and one of the tasks was to check what was previous month name and number of days. Name of a month Concept of uptime report was that script will gather start/stop/crash information from eventlog and calculate time between of those events. It …

certificate

PowerShell Tip of the Week: Get certificate remotely

Get certificate details from remote machines. In this post I wanted to share simple script which check certificates expiration date. Get certificate details To get certificates details we can use Get-ChildItem command and provide cert path Cert:\LocalMachine\My. In this example I was looking for certificates which subject contains my computer name: As you can see above we get Thumbprint and Subject properties as default. In this case expiration date is …

Event ID's

PowerShell Tip of the Week: Query multiple event ID’s remotely

In my daily work I often need to look for specific event ID’s on all computers. As my environmnet contains mostly server core machines I always use PowerShell script for checking that. Multiple event ID’s Get-WinEvent cmdlet gets events from event logs, including classic logs, such as the System and Application logs, and the event logs that are generated by the Windows Event Log technology.  It also allows you to …

Test multiple ports on remote servers using PowerShell script

Some time ago I added articles about testing connection on several ports. In one of them I was explaining how to format PortQry results and other was about PowerShell function. This time I wanted to speed up things a little bit 🙂 Testing connection We can test connection in several ways. In this case I wanted to make a test on lots of remote machines in fast way. In this …

Get Azure logs using PowerShell script

Today I wanted to show you one of the method for getting Azure logs. In this case I was looking for information about start and stop action. Azure logs To connect to Azure resources and be able to check logs you need few things: Azure Credentials Environment TenantID Subscription Resource Group Name Below you can find example for converting your password to secure string and adding it with account ID …

PowerShell Tip of the Week: SQL Server Native Client version

Recently I had to extract SQL Server Native Client version from all of my SQL machines. I would like to share simple script for extracting that information remotely from registry. SQL Server Native Client To find version using PowerShell we need to know where is it located. Easiest way for me was extracting this from registry: SQL Server 2008/2008 R2:– HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLNCLI10\CurrentVersion SQL Server 2012/2016:– HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLNCLI11\CurrentVersion You …

PowerShell Tip of the Week: Restart Web Application remotely

In todays short article I want to share few simple one-liner scripts that I’m using for Web Applications. They might be useful for your daily administration and if you want to create automated reports. Web Application pool I often need to check application pools status and depends on the output perform some actions. To use examples from this article you need WebAdministration module commands. Below you can find how to …

events

Extract dates from string and convert it to UTC

Today I want to show you how to extract dates from string. Recently I posted article about getting IP address from log file. This time its a little bit more compliacted as date format in string is invalid. Extract date from string Extracting dates from string is pretty simple if you know the regex pattern. In my case I had to get all dates from string and use it as …

lockout source

Get lockout source for currently locked users

Todays articile is about getting lockout source and checking who is currently locked in your environment. Script is based on ActiveDirectory module and Get-WinEvent commands. Currently locked users First we need to check how many users are locked. Below you can find simple script for checking that. Script is using Search-ADAccount command with LockedOut parameter. Find lockout source Next part is to find lockout source for each users. To do …

SCOM UR

Installing SCOM UR patch on remote computers

In this short articile you will find out how to install SCOM UR patch remotely. In one of the previous articile you can check also how to get information about UR version from remote machines. Installing SCOM UR Below you can find simple example for installing patch 2012 R2 UR14: In my case patch with .msp extension was located on d: drive: First script will create folder d:\temp on remote …