Chirag Nagrekar has Published 468 Answers

How to use Get-ChildItem in PowerShell to filter a specific extension?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:46:01

To get the output of the get-childitem with a specific extension, we need to use –includeparameter.ExampleIn the below example, we will use the below script to get only .xml files.Get-ChildItem D:\Temp\ -Recurse -Include *.xmlOutputPS C:\WINDOWS\system32> Get-ChildItem D:\Temp\ -Recurse -Include *.xml     Directory: D:\Temp\GPO_backup\{C9C3DB4C-2E51-4201-B3C3-7C0F1ACECBE9} Mode           ... Read More

What is the use of -Force parameter in Get-ChildItem in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:41:17

To display files along with hidden files, you need to use –Force parameter.CommandGet-ChildItem D:\Temp\ -ForceOutputIf you see the above output, hiddenfile.xlsx is the hidden file and same can be identified with the mode where –a-h—attribute of the file.You can also use this parameter with –Recurse or –Depth.Get-ChildItem D:\Temp\ -Recurse -Force ... Read More

How to display files/folders including hidden files/folders in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:40:15

To display files along with hidden files, you need to use –Force parameter.CommandGet-ChildItem D:\Temp\ -ForceOutputIf you see the above output, hiddenfile.xlsx is the hidden file and same can be identified with the mode where –a-h—attribute of the file.You can also use this parameter with –Recurse or –Depth.Get-ChildItem D:\Temp\ -Recurse -Force ... Read More

How to get only hidden files and folders in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:38:59

To display only hidden files and folders –hidden parameter is used while using Get-ChildItem.CommandGet-ChildItem D:\Temp\ -HiddenOutputPS C:\WINDOWS\system32> Get-ChildItem D:\Temp\ -Hidden     Directory: D:\Temp Mode                LastWriteTime         Length Name ----                -------------     ... Read More

How to use Depth pararmeter in Get-ChildItem PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:38:08

When –Depth parameter is used along with Get-ChildItem, it controls the recursion of displaying the subfolders and their contents. For example, if –Depth parameter is set to 1 then it will display only the content of the parent folder and immediate subfolders but not the subfolders of the subfolders.CommandWhen you ... Read More

How to control recursion in Get-ChildItem in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:37:03

When –Depth parameter is used along with Get-ChildItem, it controls the recursion of displaying the subfolders and their contents. For example, if –Depth parameter is set to 1 then it will display only the content of the parent folder and immediate subfolders but not the subfolders of the subfolders.CommandWhen you ... Read More

How to use the -recursive parameter in Get-ChildItem using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:33:19

To display the contents of the subfolders including files and folders, -Recurse parameter is used.CommandGet-ChildItem -Path D:\Temp -Recurse-Recurse parameter will not display the hidden files and folders.OutputDirectory: D:\Temp Mode                LastWriteTime         Length Name ----             ... Read More

How to list the subfolder contents using Get-ChildItem using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 23-Jan-2020 07:30:49

To display the contents of the subfolders including files and folders, -Recurse parameter is used.CommandGet-ChildItem -Path D:\Temp -Recurse-Recurse parameter will not display the hidden files and folders.OutputDirectory: D:\Temp Mode                LastWriteTime         Length Name ----             ... Read More

Which methods are supported by Get-ChildItem in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 22-Jan-2020 12:44:39

There are methods or functions which are useful for directories and file operations.Methods for the directory.TypeName: System.IO.DirectoryInfo Name                      MemberType ----                      ---------- Create                 ... Read More

How to list the directory content in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 22-Jan-2020 12:42:10

To display the directory content, Get-ChildItem cmdlet is used. You need to provide the path of the directory or if you are in the same directory, you need to use only Get-ChildItem directly. In the below example, we need to display the contents of the D:\temp directory.When Get-ChildItem command is ... Read More

Advertisements