Getting items

The Get-Item command is used to get an object represented by a path:

Get-Item  # The root container 
Get-Item .  # The current container 
Get-Item .. # The parent container 
Get-Item C:WindowsSystem32cmd.exe  # A leaf item 
Get-Item Cert:LocalMachineRoot      #A container item 

The Get-ChildItem command, which has dir and ls aliases, is used to list the children of the current item.

Neither Get-ChildItem nor Get-Item will show hidden files and folders by default. The following error will be returned for a hidden item:

PS> Get-Item $env:USERPROFILEAppData
Get-Item : Could not find item C:UsersSomeoneAppData.
At line:1 char:1
+ Get-Item $env:USERPROFILEAppData
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:UsersSomeone AppData:String) [Get-Item], IOException
+ FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.GetItemCommand

The Force parameter may be added to access hidden items:

PS> Get-Item $env:USERPROFILEAppData -Force

Directory: C:UsersSomeone

Mode LastWriteTime Length Name
---- ------------- ------ ----
d--h-- 23/09/2016 18:22 AppData
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.189.247