Chirag Nagrekar has Published 468 Answers

How to clear all values from the Hash table in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Feb-2020 10:18:15

Hash table in the PowerShell session is created temporarily. It is like a variable, when the session is closed, hash table is deleted automatically. If you want to delete all the values from the hash table at once but retaining the hash table variable, you need to use the Clear() ... Read More

How to add and remove values to the Hash Table in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Feb-2020 10:15:05

You can add values to the hash table and remove values from the hash tables. To add the values to the hash table, you need to use the below format.$hash["<key>"] = "<value>"We have hash table already created here, $htable = [Ordered]@{EmpName="Charlie";City="New York";EmpID="001"}PS C:\WINDOWS\system32> $htable Name       Value ---- ... Read More

How to create a Hash Table in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Feb-2020 10:09:07

There are several ways to create a Hash Table in PowerShell. We will discuss here the standard method @{} for creating the Hash Table.Using @{} MethodYou can use @{} method to create a hash table. Key-Value pair is separated with the Semi-Colon (;). You can only add unique keys. Duplicate ... Read More

What is Hash Table in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Feb-2020 10:06:13

Hash table in a PowerShell is constructed with the Key-Value combination. Each key has its own value, so to get the value we need to refer the Key. We don’t need numeric indexing like Array to refer values.This is how the hash table looks like.Name       Value ... Read More

How to create PowerShell alias permanently?

Chirag Nagrekar

Chirag Nagrekar

Updated on 14-Feb-2020 08:07:54

PowerShell alias can be created permanently by 2 methods below.a) Import / Export AliasTo export all the aliases, you need to use Export-Alias cmdlet. When you use this command it will ask you the path for the file to import.To export the newly created alias, you need to give alias ... Read More

How to create new alias with PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 14-Feb-2020 08:06:31

Anyone can create a new alias which is a shortcut to another command. To create your own alias you need to use Set-Alias cmdlet. Here, we will create a new alias Edit, which will open a Notepad.exe. First, we will check if Edit alias exists or not.$Alias:EditAs this is going ... Read More

How to get all the aliases in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 14-Feb-2020 08:05:45

In PowerShell, you will get all the alias and their commands using Alias: drive as shown below.Dir Alias:OutputHere, Alias: is the drive but surprisingly you will not find it in your operating system. This is the virtual drive and there are other virtual drives as well. You can list all ... Read More

How to get/resolve the command from the alias in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 14-Feb-2020 08:03:32

To resolve the command name from given alias, you need to use the below command.$Alias:AliasNameFor example, $Alias:dirOR$Alias:lsOutputGet-ChildItemThis means the above commands will provide the same result. For example, the output of the below commands would remain the same.Get-ChildItem C:\ Dir C:\ ls COutputYou can also use Get-Alias to resolve the ... Read More

What is an alias in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 14-Feb-2020 08:02:55

In general, Alias means giving command to other names. In system admin life, they want short and familiar commands. PowerShell has verb-noun cmdlets that are very systematic but not practical in everyday life. So the System admins use PowerShell alias. For example - Dir or ls for the Get-ChildItem, cat or ... Read More

How to get the list of all the commands available in the PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 14-Feb-2020 08:01:44

To get the list of all the commands installed in the system use the below command line. It will include all the Alias, Functions and Cmdlets.Get-CommandTo export them into the CSV file, Get-Command | Export-Csv D:\Temp\PowerShellcommands.csv - NoTypeInformationTo get only the cmdlets commands, Get-Command -CommandType CmdletSimilarly, you can get the ... Read More

Advertisements