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 …

Get-Process

Get process remotely including username using PowerShell

In today’s article I would like to describe how to get process remotelty used by some specific username. Most of PowerShell admins are familiar with this command but no all knows its paramter called IncludeUserName. Recently I had to check processes under some username on bunch of servers. Below you can find few helpful examples. Get process locally Get all processes for some specific user is not difficult. Paramter -IncludeUserName …

Log lines

Extract IP address from log lines using PowerShell

Recently I had to extract IP Addresses from log file and check their hostnames. The easiest way to get this was using regex pattern in Select-String command. Extract IP Address Lets says that we have a log file which contains lines like: AUDIT “2018-06-19 00:14:16.481 GMT+0200” 10.13.11.7 Server01:1812 0 0 “text=Access GRANTED cloudId=pawel.janowicz To extract IP Address from it we can use Select-String command with the following regex pattern “\d{1,3}(\.\d{1,3}){3}”>: …

Test URL on Server Core machines using PowerShell

Recently I had to test URL on server core machines. I created simple scripts to generate report with just basic information like status code and content. Below you can find short description how to check http and https URLs. Test URL For checking http URL I used Invoke-WebRequest command. Unfortunately when I run it localy on server core machine it returned me an error: Error message: The response content cannot …

Get domain role and PC type from remote computers

Today I want to show how to get domain role and PC type using PowerShell function. You can get this information easily using 1 liner script but results will be presented as numbers. Domain role and PC type Function is based on Get-WmiObject command and it query Win32_computersystem class. To get “PC type” and “Domain Role” using just one command we have to use Select-Object cmdlet after the pipeline: Unfortunelty …

ADFS_product_version

Get ADFS product version using PowerShell

In this short arcticle you’re gonna find out how to check ADFS product version on multiple remote servers. Recently I had to scan my environment for auditing purpose. One of the tasks was to compare ADFS service product version. ADFS product version To check it on single machine we can use Get-Item cmdlet: It getting a little bit more complicated if you have plenty of severs and they are Server …

How to create dump files remotely (ProcDump) using PowerShell?

Recently I had to create memory dump files for multiple remote servers. I found great tool called ProcDump on Microsoft page which can do it. Unfortunately it can’t be run remotely so I had to combine this tool features with PowerShell commands. ProcDump ProcDump is a command-line utility whose primary purpose is monitoring an application for CPU spikes and generating crash dumps during a spike that an administrator or developer …

free disk space

Get free disk space from remote computers

One of the things that you have to monitor in your environment is free disk space. In this short article I want to share with you some code lines which help to create disk report. Free disk space Script is based on Get-WmiObject cmdlet which gets instances of Windows Management Instrumentation (WMI) classes or information about the available WMI classes. For more information please refer to Microsoft docs page. Script …

How to add progress bar in your PowerShell scripts?

Today you will learn how to add progress bar in your code. In last post I described how to combine CSV files and this time I’m gonna show how to use those files and add cool feature to script. Progress bar Script is based on Write-Progress cmdlet which displays a progress bar in a Windows PowerShell command window that depicts the status of a running command or script. You can …