Chirag Nagrekar has Published 465 Articles

Explain secure password Encryption with PowerShell.

Chirag Nagrekar

Chirag Nagrekar

Updated on 16-May-2020 10:59:37

321 Views

Many times we need to use passwords in PowerShell and need to pass it to the credential parameter and a password should be always a secure string, not a plain text. There are few methods to encrypt the password as mentioned below.a) Get-Credential FormatWe have one method where we can ... Read More

What is the difference between –Match, -Like and –Contains Operator in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 15-May-2020 13:05:42

6K+ Views

All the above 3 operators (Match, Like, and Contains) mentioned are the comparison operator in PowerShell. Match and Like operators are almost similar operator only difference is the Wildcard character and the Contains operator is entirely different. We will see the example and understand how they work.ExamplePS C:\WINDOWS\system32> "This is ... Read More

How to write Progress Bar in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 15-May-2020 13:03:20

2K+ Views

When we write a script in PowerShell, users who execute it, expect to see the progress of the script instead of waiting idle and looking at the blank cursor while the script is executing the background task. One way to achieve is to use the Verbose parameter to see the ... Read More

How to remove empty string/lines from PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 15-May-2020 12:57:43

7K+ Views

In many instances, you need to remove empty lines or strings from the PowerShell string array or the files. In this article instead of removing empty string, we will get the result or filter the output from lines that are not empty. In this way, we can get the output ... Read More

How to get the port number of the processes using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-May-2020 13:22:15

2K+ Views

When we use Get-Process cmdlet in PowerShell, it doesn’t have properties to get Port number the processes use. So here we will write a function that will provide us the ports number associated with the processes.There is one windows command NETSTAT which provides the Port number and the associated process ... Read More

Explain ValueFromPipeline in PowerShell Advanced Functions.

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-May-2020 07:15:45

4K+ Views

Consider the below example, we have created Advanced function to get the specific process information like Process Name, Process ID (PID), Start Time, Responding status, etc.function Get-ProcessInformation{    [cmdletbinding()]    param(       [Parameter(Mandatory=$True)]       [string[]]$name    )    Begin{       Write-Verbose "Program started"   ... Read More

Explain AllowEmptyString() and AllowEmptyCollection() in PowerShell Advanced Function.

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-May-2020 07:04:15

3K+ Views

AllowEmptyString() attribute works with the string variable and AllowEmptyCollection() work with the array of different data types (Collection).Consider the example below. Here, we are using a mandatory variable $name which is a string and $stringarray which is a string array.function print_String{    [cmdletbinding()]    param(       [parameter(Mandatory=$True)]   ... Read More

Explain the Mandatory Attribute in PowerShell Advanced Function.

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-May-2020 07:01:04

347 Views

We have an example of PowerShell advanced function below and we will try to understand how mandatory parameter works.function math_Operation{    [cmdletbinding()]    param([int]$val1, [int]$val2)    Write-Host "Multiply : $($val1*$val2)"    Write-Host "Addition : $($val1+$val2)"    Write-Host "Subtraction : $($val1-$val2)"    Write-Host "Divide : $($val1+$val2)" }When you execute the above ... Read More

Explain the PowerShell Advanced Function.

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-May-2020 06:56:58

530 Views

Before starting the Advance PowerShell function, assuming we know about the PowerShell function. You can check the explanation on the PowerShell function below.https://www.tutorialspoint.com/explain-the-powershell-functionHere, we will take the math function example that calculates the different types of operations. We already have a code with the simple function as shown below.function math_Operation{ ... Read More

How to pass the parameters in the PowerShell function?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-Apr-2020 12:36:16

17K+ Views

You can pass the parameters in the PowerShell function and to catch those parameters, you need to use the arguments. Generally, when you use variables outside the function, you really don’t need to pass the argument because the variable is itself a Public and can be accessible inside the function. ... Read More

Advertisements