PowerShell Core Commands
In this tutorial we will see about Windows PowerShell Core Commands. Below is the explanation provided by Microsoft for those commands.
PowerShell includes a set of cmdlets that are specifically designed to manage the items in the data stores that are exposed by Windows PowerShell providers. You can use these cmdlets in the same ways to manage all the different types of data that the providers make available to you.
Below we will see the list of those commands, what they do and and some examples.
Windows PowerShell Core Commands List:
- ChildItems cmdlets
Get-ChildItem
– Gets the items and child items in one or more specified locations.
- Content cmdlets
Add-Content
– Adds content to the specified items, such as adding words to a file.Clear-Content
– Deletes the contents of an item, but does not delete the item.Get-Content
– Gets the content of the item at the specified location.Set-Content
– Writes or replaces the content in an item with new content.
- Item cmdlets
Clear-Item
– Clears the contents of an item, but does not delete the item.Copy-Item
– Copies an item from one location to another.Get-Item
– Gets the item at the specified location.Invoke-Item
– Performs the default action on the specified item.Move-Item
– Moves an item from one location to another.New-Item
– Creates a new item.Remove-Item
– Deletes the specified items.Rename-Item
– Renames an item in a Windows PowerShell provider namespace.Set-Item
– Changes the value of an item to the value specified in the command.
- ItemProperty cmdlets
Clear-ItemProperty
– Clears the value of a property but does not delete the property.Copy-ItemProperty
– Copies a property and value from a specified location to another location.Get-ItemProperty
– Gets the properties of a specified item.Move-ItemProperty
– Moves a property from one location to another.New-ItemProperty
– Creates a new property for an item and sets its value.Remove-ItemProperty
– Deletes the property and its value from an item.Rename-ItemProperty
– Renames a property of an item.Set-ItemProperty
– Creates or changes the value of a property of an item.
- Location cmdlets
Get-Location
– Gets information about the current working location or a location stack.Pop-Location
– Changes the current location to the location most recently pushed onto the stack.Push-Location
– Adds the current location to the top of a location stack.Set-Location
– Sets the current working location to a specified location.
- Path cmdlets
Join-Path
– Combines a path and a child path into a single path.Convert-Path
– Converts a path from a Windows PowerShell path to a Windows PowerShell provider path.Split-Path
– Returns the specified part of a path.Resolve-Path
– Resolves the wildcard characters in a path, and displays the path contents.Test-Path
– Determines whether all elements of a path exist.
- PSDrive cmdlets
Get-PSDrive
– Gets drives in the current session.New-PSDrive
– Creates temporary and persistent mapped network drives.Remove-PSDrive
– Deletes temporary Windows PowerShell drives and disconnects mapped network drives.
- PSProvider cmdlets
Get-PSProvider
– Gets information about the specified Windows PowerShell provider.
Some Examples
Now we are going to see some examples of the first two categories of the above commands. As the above commands can be used in many ways, it is best to check each one of them separately to better understand their use. I not going to provide examples for each one of them in this tutorial. It will make the tutorial huge and full of screenshots, therefore it will be difficult to read.
There are different use cases that you can apply each one of them, in different ways and of course there are parameters that you can define their behaviour. The examples below are just simple ones, to help you get an idea of what you can do with them, there are much more things that you can do with the above commands.
If you want to check more about each command. I have provided you below, in related links section, the link of each command that directs you to Microsoft documents. There you can find a lot of information about the commands and their parameters including examples.
[adinserter name=”In Article”]
Get-ChildItem
Example 1
Get the files under a specific folder.
Code:
Get-ChilItem -Path "C:\Scripts_Output"
Output:
Example 2
Get registry items under specific path.
Code:
Get-ChildItem -Path "HKLM:\Hardware\Description\System"
Output:
Example 3
Get all alias in the current session
Code:
Get-ChildItem -Path "Alias:\"
Output:
[adinserter name=”In Article”]
Add-Content
Below is the file before running the below command.
Code:
Add-Content -Path "C:\Scripts_Output\file1.txt" -Value "Hello World!!!"
Output:
Get-Content
We will use the same file that we added content on the previous example.
Code:
Get-Content -Path "C:\Scripts_Output\file1.txt"
Output:
[adinserter name=”In Article”]
Set-Content
Below is the content before running the below command
Code:
Set-Content -Path "C:\Scripts_Output\file1.txt" -Value "This is my world!!!"
Output
[adinserter name=”In Article”]
Clear-Content
After we have change the content of the file by running the below command we can clear any content inside
Code:
Clear-Content -Path "C:\Scripts_Output\file1.txt"
Output:
I hope the tutorial about PowerShell Core Commands is helpful.
Please let me know your comments and thoughts.
You feedback is appreciated.
[adinserter name=”In Article”]
Related Links:
- PowerShell Scripts
- PowerShell Tutorials
- PowerShell Providers
- about_Core_Commands | Microsoft Docs
- Get-ChildItem – Microsoft Docs
- Add-Content – Microsoft Docs
- Clear-Content – Microsoft Docs
- Get-Content – Microsoft Docs
- Set-Content – Microsoft Docs
- Clear-Item – Microsoft Docs
- Copy-Item – Microsoft Docs
- Get-Item – Microsoft Docs
- Invoke-Item – Microsoft Docs
- Move-Item – Microsoft Docs
- New-Item – Microsoft Docs
- Remove-Item – Microsoft Docs
- Rename-Item – Microsoft Docs
- Set-Item – Microsoft Docs
- Clear-ItemProperty – Microsoft Docs
- Copy-ItemProperty – Microsoft Docs
- Get-ItemProperty – Microsoft Docs
- Move-ItemProperty – Microsoft Docs
- New-ItemProperty – Microsoft Docs
- Remove-ItemProperty – Microsoft Docs
- Rename-ItemProperty – Microsoft Docs
- Set-ItemProperty – Microsoft Docs
- Get-Location – Microsoft Docs
- Pop-Location – Microsoft Docs
- Push-Location – Microsoft Docs
- Set-Location – Microsoft Docs
- Join-Path – Microsoft Docs
- Convert-Path – Microsoft Docs
- Split-Path – Microsoft Docs
- Resolve-Path – Microsoft Docs
- Test-Path – Microsoft Docs
- Get-PSDrive – Microsoft Docs
- New-PSDrive – Microsoft Docs
- Remove-PSDrive – Microsoft Docs
- Get-PSProvider – Microsoft Docs
[adinserter name=”Matched-Content”]


Leave a Reply