PowerShell Tip of the Week: Create Invoke-WebRequest from Chrome

This week PowerShell tip will show you how to create Invoke-WebRequest from Chrome. Each scripter who wanted to properly use Invoke-WebRequest command to access some url knows that it is not so easy. Every time headers or some additional settings must be adjusted to properly gather all the data. Last update of Chrome web browser gives awesome functionality for PowerShell developers. In Chrome Dev Tools option to copy whole Invoke-WebRequest …

PowerShell Tip of the Week: Compare two CSV files

In this article I wanted to show you how to compare two CSV files using Compare-Object command. It might be useful if you run some scans on regular basis and want to check if they contains the same data. Compare-Object Script is based on Compare-Object cmdlet which compares two sets of objects. One set of objects is the “reference set,” and the other set is the “difference set.” The result …

PowerShell Tip of the Week: Combine multiple CSV files

Recently I had to combine multiple files and count unique users from them. Script is pretty simple but it might me useful in some troubleshooting sessions. Below you can find two examples about how can this be done. Combine CSV files I created folder called Files on my desktop and pasted there user lists in CSV format. Files contains multiple columns but I was focusing only on Samaccountname: File example …

PowerShell Tip of the Week: Check connectivity to multiple servers

You can find multiple articles on our blog about checking connectivity. This time I want to show you how to check it for bunch of servers on specific port. Check connectivity Script will use Test-NetConnection command where you can specify port number. For single machine you can use the following one-liner script: On the beginning you have to provide servers and destination servers againts which you want to check connection: …

PowerShell Tip of the Week: Building your first chart report

Today’s short tip will be about building your first chart report. You can find several articles on our blog about memory utilization. This time you will learn how to get results in columns chart. Chart report As some of you already know PowerShell allows you to create charts and graphs. To do this we need to use .Net classes. The System.Windows.Forms.DataVisualization.Charting namespace contains methods and properties for the Chart Windows …

PowerShell Tip of the Week: Uninstall SCCM client

Today’s short tip is about SCCM client uninstall process. One of the tasks for complete client removal is of course running ccmsetup.exe uninstall command. To do this for a bunch of servers we can use Invoke-Command. Uninstall SCCM client On the beginning its worth to check if ccmsetup.exe file exist on affected machine. To verify this we are going to use Test-Path command which will return “True” of “False” value: …

PowerShell Tip of the Week: File browser

Today’s tip will be about file browser in PowerShell. Its a nice feature where you can just select the server list instead of writing path inside the code. File browser To select the file we’re gonna use System.Windows.Forms. The System.Windows.Forms namespace contains classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows operating system. For more information please visit technet …

PowerShell Tip of the Week: Get FQDN

Today I want to show you how to use .Net class to get FQDN (Fully Qualified Domain Name). A fully qualified domain name is the complete domain name for a specific computer. The FQDN consists of two parts: the hostname and the domain name like for example: DC01.powershellbros.com Get FQDN In this article we will focus on DNS class which is a static class that retrieves information about a specific …

PowerShell Tip of the Week: Taskkill remotely

Taskkill command can be very useful when it comes to daily operational tasks. I often had situation that several ADFS web servers were not working properly. Recently I’ve been flooded by SCOM alerts about service failure. First recommended step is to restart ADFS service. Unfortunately normal service restart does not solve the issue. Taskkill command comes to rescue – it allows to terminate completely affected process. Taskkill Ends one or …

PowerShell Tip of the Week: Get IP address

There are multiple ways to get IP address information. Most common are ipconfig or Get-NetIPAddress command. Today I want to show you how to check this quickly using ping class. Get IP address To check IP configuration we can use one of the following one-liner commands Our script is based on .NET Framework System.Net.NetworkInformation ping class: Output: Results will be displayed in console and at the end saved into CSV …