Chirag Nagrekar

Chirag Nagrekar

394 Articles Published

Articles by Chirag Nagrekar

Page 34 of 40

What is Copy-item in PowerShell used for?

Chirag Nagrekar
Chirag Nagrekar
Updated on 12-Mar-2020 390 Views

Copy-Item in PowerShell cmdlet is used for copying items from one location to another location in the same namespace. Here, the namespace meaning, you can copy items from files to the different folders but cannot files to the registry or the certificate store.This cmdlet doesn’t delete or cut the item from the source location instead, it copies the item to the destination folder with the same name or the different name.Copy-Item Syntax with parameters in PowerShell is as below.Copy-Item    [-Path]    [-LiteralPath]    [[-Destination] ]    [-Container]    [-Force]    [-Filter ]    [-Include ]    [-Exclude ...

Read More

How to add/merge two hash tables in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 26-Feb-2020 4K+ Views

Adding values of the hash table is simple as the adding string. We just need to use the addition operator (+) to merge two hash table values.Here, we have two hash tables: $htable and $htable1.$htable = [Ordered]@{EmpName="Charlie";City="New York";EmpID="001"} $htable1 = [Ordered]@{Fruit='Apple';Color='Red'}We will now add two hash tables,$htable + $htalble1PS C:\WINDOWS\system32> $htable+$htable1 Name       Value ----       ----- EmpName    Charlie City       New York EmpID      001 Fruit      Apple Color      Red

Read More

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

Chirag Nagrekar
Chirag Nagrekar
Updated on 26-Feb-2020 20K+ Views

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[""] = ""We have hash table already created here, $htable = [Ordered]@{EmpName="Charlie";City="New York";EmpID="001"}PS C:\WINDOWS\system32> $htable Name       Value ----       ----- EmpName    Charlie City       New York EmpID      001We need to add additional key “Dept” in the above hash table with the value “Technical”.$htable['Dept']="Technical"When you check the output of the above Hashtable, you can see the key-value is appended to the table.PS ...

Read More

What is Hash Table in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 26-Feb-2020 652 Views

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 ----       ----- EmpName     Charlie City       New York EmpID       001In the hash table creation, keys and values are separated with Semi-colons (;). In the above example, EmpName, City and EmpID are referred as keys while Charlie, New York ...

Read More

How to create PowerShell alias permanently?

Chirag Nagrekar
Chirag Nagrekar
Updated on 14-Feb-2020 4K+ Views

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 name and the name for the export, so later you can import it with the same name.In the below example, we have created alias name Edit for the Wordpad and we will export all the aliases with the name Alias1, so the newly created alias will also be stored and ...

Read More

How to get all the aliases in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 14-Feb-2020 453 Views

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 the virtual drives using the below command.Get-Alias will provide the same result.The above output provides the individual alias and their commands for it. But to group them based on their cmdlets, you need to use Group-Object command.Dir Alias: | Group-Object DefinitionOutputYou will see in the output that aliases are listed ...

Read More

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

Chirag Nagrekar
Chirag Nagrekar
Updated on 14-Feb-2020 423 Views

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 alias name. For example, Get-Alias -Name dirGet-Alias -Name lsUntil now we need to remember alias name to get the command and we were running individual commands to get the Alias and its command. It is possible to get all the alias names for the given command. To get all aliases ...

Read More

What is an alias in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 14-Feb-2020 277 Views

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 gc for the Get-Content.

Read More

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

Chirag Nagrekar
Chirag Nagrekar
Updated on 14-Feb-2020 3K+ Views

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 commands for the alias and functions.If you want the list of commands starting with getting, you parameter –Verb.Get-Command -Verb GetTo get command starting with Set,Get-Command -Verb Set

Read More

How to start any program using PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 14-Feb-2020 13K+ Views

If you have noticed, you can start notepad and calculator or other standard system utilities with the Windows Run or through the PowerShell console directly by typing just their names, but not the wordpad.exe, word, excel or any other application. It will throw an exception.For example, just type notepad.exe in PowerShell console and it will open the program but type wordpad.exe there will be an error.wordpad.exe − The term 'wordpad.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the ...

Read More
Showing 331–340 of 394 articles
« Prev 1 32 33 34 35 36 40 Next »
Advertisements