Chirag Nagrekar has Published 465 Articles

How to format string using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Jan-2021 07:32:31

5K+ Views

To format a string in a PowerShell we can use various methods. First using the simple expanding string method.PS C:\> $str = 'PowerShell' PS C:\> Write-Output "Hello $str !!!!" Hello PowerShell !!!!Second, using the format method. In this method, we will use the Format function of the String .NET class.PS ... Read More

How to check the website status code using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Jan-2021 07:31:12

9K+ Views

Website status code is meant to be the status of the website as if the website request from the client is successful or not if the website is available or any error on the webpage which is causing the handshake failed with the client.There are various website status codes. Please ... Read More

How to get website links using Invoke-WebRequest in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Jan-2021 07:29:34

4K+ Views

To get the links present on the website using PowerShell, we can first retrieve the data from the webpage using the Invoke-WebRequest cmdlet.$req = Invoke-WebRequest -uri "https://theautomationcode.com" $reqOutputTo retrieve only links we can use that property and there you will also find some sub-properties like InnerHTML, Innertext, href, etc as ... Read More

How to download images using Invoke-Webrequest in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Jan-2021 07:26:10

3K+ Views

To download the images from the webpage using the Invoke-WebRequest command, we can use the images property from the result to retrieve the images URL, and later we can use the method to download them at the specific location. Consider we have the URI: https://theautomationcode.com to retrieve the images.Once you ... Read More

How to use Array Splatting in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Jan-2021 07:23:45

521 Views

Splatting is the method to pass the collection of parameters as a single unit so it will be easier for the command to read. Array splatting uses the splat values which do not require parameter names. The values must be in positional number order in the array.We have a below ... Read More

How to use Hashtable splatting in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Jan-2021 07:21:18

663 Views

Splatting is the way to pass the collection of the parameters to the command as a single value. It uses the Hashtable splatting means that we can pass the Name and Value pair combination. We can use the named positional parameter for this with the values we want to provide.For ... Read More

What is splatting in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 18-Jan-2021 07:20:14

268 Views

PowerShell splatting is a method to pass the collection of the parameters as a single command unit which makes the command shorter and easier for the user to read commands. Splatting uses the symbol (@) instead of ($) which tells the user that splatting is used and PowerShell is passing ... Read More

How to use PSCustomObject in PowerShell foreach parallel loop?

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-Jan-2021 10:03:29

3K+ Views

To use the PSCustomObject inside the Foreach Parallel loop, we first need to consider how we are using the variables inside the loop.$Out = "PowerShell" ForEach-Object -Parallel{    Write-Output "Hello.... $($using:Out)" }So let see if we can store or change a value in the $out variable.Example$Out = @() ForEach-Object -Parallel{   ... Read More

How to work with Invoke-Command Scriptblock output?

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-Jan-2021 10:01:18

7K+ Views

When we simply write the Invoke-Command, it shows the output on the console.ExampleInvoke-Command -ComputerName Test1-Win2k12 -ScriptBlock {Get-Service}OutputIt shows the output along with the computer name.Now let's say you want to sort the output or you want to work with the output you need to store it. It is similar like ... Read More

How to check which Azure account is logged in using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 04-Jan-2021 09:58:54

3K+ Views

To check the logged-in Azure user account in the console using PowerShell, you can check the context of the Azure and for that Get-AZContext command is used.ExampleGet-AzContextOutputIf you are already logged in with multiple user accounts then there may be chances that there are multiple contexts available, to list all the ... Read More

Advertisements