PowerShell’s Get-ChildItem has a little sister called Get-Item.
Topics – Examples of Get-Item
- Real Life Example: List Environmental Variables
- Research Get-Item’s Parameters
- Find the Alias of Get-Item
- Summary – PowerShell Script to Delete Files
Our mission here is to list all the Environmental Variables. For example, if we want to research which folder holds the user’s profile files.
# PowerShell script to list Environmental Variables paths
# PowerShell script to list Environmental Variables
See more about Env:temp
SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
# PowerShell Get-Item parameters.
Get-Help Get-Item -Full
The principle difference between Get-Item and Get-ChildItem, is the later has a -Recurse parameter.
Differences Between Get-Item and Get-ChildItem
Get-Item returns information on just the object specified, whereas Get-ChildItem lists all the objects in the container. Take for example the C:\ drive.
# PowerShell difference between Get-Item and Get-ChildItem.
Mode LastWriteTime Length Name
—- ————- —— —-
d–hs 22/12/2012 13:22 C:\
Get-ChildItem would list all the files and folders under the C:\ Incidentally, you could get the same effect by adding a wildcard.
Get-Item C:\* is the same as plain Get-ChildItem C:\
While the behaviour of these two cmdlets is very similar, there a few differences which can catch you unawares. My conclusion is stick with Get-ChildItem, I have yet to find a killer use of the shorter Get-Item.
Get-ChildItem has the famous alias gci, but what of Get-Item?
# PowerShell technique to find an alias.
Get-Alias -Definition Get-Item
Alias gi -> Get-Item
Summary of PowerShell Get-Item
Get-Item does what says: namely it returns the properties of the object specified. In this example it enables us to research the operating system’s environmental variables.
If you like this page then please share it with your friends
See More Windows PowerShell Examples of Real-life Tasks
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.