Chirag Nagrekar has Published 465 Articles

How to use the foreach loop parallelly in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 19-Feb-2021 13:05:09

9K+ Views

There are two ways to use the foreach loop parallelly in PowerShell.Using Foreach-Object -Parallel command (Supports in PowerShell 7.0 or above)Using Foreach -Parallel in Workflow (Supports PowerShell 5.1 or below)Suppose we have Servers.txt and which contains 10 Servers. When we use the Parallel for loop, it isn’t guaranteed which server ... Read More

What is the PowerShell Workflow?

Chirag Nagrekar

Chirag Nagrekar

Updated on 19-Feb-2021 13:01:31

366 Views

PowerShell workflow is built on the .Net based Windows Workflow Foundation (WWF) and it has a separate Workflow engine to execute the code because it translates code into XAML for the WWF framework.PowerShell workflow is series of steps that is mainly used forRunning activities parallelly on more than one machine.Long-running ... Read More

How to validate the IP address using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 19-Feb-2021 12:59:09

2K+ Views

To validate the IP address using PowerShell, we can use several methods as shown below.Using RegEx method.Using Typecasting method.Using TypeCasting method.In this method, we are using System.Net method class IPAddress to validate the IP address.[ipaddress]$IP = "192.168.0.1"The above one is valid. Let’s check what $IP stores in.PS C:\> $IP ... Read More

How to check if the string contains the specific word?

Chirag Nagrekar

Chirag Nagrekar

Updated on 08-Feb-2021 07:55:01

1K+ Views

To check if the PowerShell string contains a specific word, we can use the string method Contains(). For example, ExamplePS C:\> $str = 'TestNZ01LT' PS C:\> $str.Contains('NZ') TrueNow the funny thing is, even if the PowerShell is case-Insensitive, the above command is not. We need to provide the exact substring. ... Read More

How to convert command output to the Hashtable format in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 08-Feb-2021 07:53:26

2K+ Views

To convert any command output to the hashtable in PowerShell, we can first convert the output to the JSON format using the ConvertTo-JSON command, and applying the ConvertFrom-JSON command from the first output will produce an output to the Hashtable.ExampleGet-ServiceThe above command will give the output in the array format.OutputStatus ... Read More

How to exclude the RunSpaceID property from the Invoke-Command output in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 08-Feb-2021 07:51:36

3K+ Views

When we write Invoke-Command in PowerShell, sometimes we get the RunSpaceID property in PowerShell. This is because we use Select-Object (alias: Select) command inside the scriptblock. For example, ExampleInvoke-Command -ComputerName LabMachine2k12 -ScriptBlock{Get-Process PowerShell | Select Name, CPU, WorkingSet}OutputName           : powershell CPU         ... Read More

How to exclude PSComputerName property from Invoke-Command output in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 08-Feb-2021 07:49:29

815 Views

When we are working with Invoke-Command, we get the PSComputerName extra field in the output table. You can remove it by using -HideComputerName parameter. For example, the Below command gives the output with the PSComputerName property.ExampleInvoke-Command -ComputerName LabMachine2k12 -ScriptBlock{Get-Service Winrm} | ft -AutoSizeOutputStatus  Name  DisplayName ... Read More

How to find the device driver version using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 08-Feb-2021 07:46:08

4K+ Views

To find the device driver version using PowerShell, we need to use the class win32_PnpSignedDriver of the WMI object. For example, ExampleGet-WmiObject win32_PnpSignedDriverOr if you are using PowerShell core (PowerShell 6.0 or later), you can use the CIM Instance command. For example, Get-CimInstance win32_PnpSignedDriverTo filter out the Drivers against their ... Read More

How to check windows certificate expiry date using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 08-Feb-2021 07:44:24

3K+ Views

To get the particular windows certificate expiry date from the particular store, we first need the full path of that certificate along with a thumbprint. If the thumbprint is not known to you, we can use the friendly name.With the thumbprint, Get-ChildItem Cert:\LocalMachine\root\0563B8630D62D75 | fl *When you run the above ... Read More

How to get the Windows certificate details using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 08-Feb-2021 07:42:37

34K+ Views

We know that the Windows Certificates are resided in the Certificate store but finding the certificate with its name or getting particular certificate details might be cumbersome sometimes.You can access the certificate store using MMC or using CertMgr.msc command. There are certificates stored for CurrentUser, ServiceAccount, and Local Computer. To ... Read More

Advertisements