• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Stephanos Constantinou Blog

PowerShell Scripting

  • Home
  • Blogs
    • PowerShell Tutorials
    • PowerShell Scripts
    • PowerShell Modules
      • Modules Cmdlets
    • Software Reviews
  • About
  • Contact
You are here: Home / PowerShell Tutorials / PowerShell Core Commands

PowerShell Core Commands

09/07/2018 by Stephanos Leave a Comment

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:

PowerShell Core Commands - Get-ChildItem for Files

Example 2

Get registry items under specific path.

Code:

Get-ChildItem -Path "HKLM:\Hardware\Description\System"

Output:

PowerShell Core Commands - Get-ChildItem for Registry

Example 3

Get all alias in the current session

Code:

Get-ChildItem -Path "Alias:\"

Output:

PowerShell Core Commands - Get-ChildItem for Aliases

 

[adinserter name=”In Article”]

Add-Content

Below is the file before running the below command.

PowerShell Core Commands - Add-Content Empty File

Code:

Add-Content -Path "C:\Scripts_Output\file1.txt" -Value "Hello World!!!"

Output:

PowerShell Core Commands - Add-Content After File

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:

PowerShell Core Commands - Get-Content File

 

[adinserter name=”In Article”]

Set-Content

Below is the content before running the below command

PowerShell Core Commands - Add-Content After File

Code:

Set-Content -Path "C:\Scripts_Output\file1.txt" -Value "This is my world!!!"

Output

PowerShell Core Commands - Set-Content to File

PowerShell Core Commands - Set-Content After File

 

[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:

PowerShell Core Commands - Clear-Content Console

 

PowerShell Core Commands - Add-Content Empty File

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”]

Summary
PowerShell Core Commands
Article Name
PowerShell Core Commands
Description
PowerShell Core Commands. in this tutorials you can find information about PowerShell Core Commands. Stephanos Constantinou Blog
Author
Stephanos
Publisher Name
Stephanos Constantinou Blog
Publisher Logo
Stephanos Constantinou Blog

Filed Under: PowerShell Tutorials Tagged With: Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty, Convert-Path, Copy-Item, Copy-ItemProperty, Get-ChildItem, Get-Content, Get-Item, Get-ItemProperty, Get-Location, Get-PSDrive, Get-PSProvider, Invoke-Item, Join-Path, Move-Item, Move-ItemProperty, New-Item, New-ItemProperty, New-PSDrive, Pop-Location, Push-Location, Remove-Item, Remove-ItemProperty, Remove-PSDrive, Rename-Item, Rename-ItemProperty, Resolve-Path, Set-Content, Set-Item, Set-ItemProperty, Set-Location, Split-Path, Test-Path

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Footer

Recent Posts

  • ICS Cube Product Review 26/04/2019
  • PowerShell Module SysInfo v1.2.0 15/03/2019
  • PowerShell Module SysInfo v1.1.2 13/11/2018
  • PowerShell Module SysInfo 24/10/2018
  • Get-VoltageProbe 24/10/2018
  • Get-VideoController 24/10/2018
  • Get-USBController 24/10/2018
  • Get-TrackPoint 24/10/2018
  • Get-TrackBall 24/10/2018
  • Get-TouchScreen 24/10/2018
Planet PowerShell

Categories

  • Modules Cmdlets (57)
  • PowerShell Modules (5)
  • PowerShell Scripts (38)
  • PowerShell Tutorials (35)
  • Software Reviews (2)

Archives

  • April 2019 (1)
  • March 2019 (1)
  • November 2018 (1)
  • October 2018 (56)
  • September 2018 (13)
  • August 2018 (9)
  • July 2018 (6)
  • June 2018 (8)
  • May 2018 (7)
  • April 2018 (9)
  • March 2018 (4)
  • February 2018 (6)
  • January 2018 (12)
  • December 2017 (4)
Top 10 PowerShell 2018

Blogroll

  • Planet PowerShell
  • Reddit – PowerShell
  • PowerShell Magazine
  • PowerShell.org
  • PowerShell Team Blog
  • Hey, Scripting Guy! Blog
  • Mike F Robbins
  • PowerShell Explained with Kevin Marquette
  • Mike Kanakos – Network Admin
  • The Lonely Administrator
  • AskME4Tech
PowerShell Blogs Sysadmin Blogs Banners for Top 20 Programming Blogs

© 2023 · Stephanos Constantinou Blog

  • Home
  • Blogs
  • About
  • Contact
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok