PowerShell Articles

Page 36 of 40

How to exclude specific extension in Get-ChildItem in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 23-Jan-2020 4K+ Views

To exclude specific extensions, you need to use –Exclude parameter in Get-ChildItem.ExampleFor example, as shown below when we run command, it will exclude .html files and display the rest.Get-ChildItem D:\Temp\ -Recurse -Exclude *.htmlOutputDirectory: D:\Temp Mode                LastWriteTime         Length Name ----                -------------         ------ ---- d-----       24-11-2018     11:31                LGPO     Directory: D:\Temp\LGPO Mode                LastWriteTime         Length Name ---- ...

Read More

How to use the wildcard character (*) in Get-ChildItem in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 23-Jan-2020 3K+ Views

You can also search for files with a specific name or using the wildcard (*) character.CommandBelow command will search for the files (including hidden files) starting with “Bac”.Get-ChildItem D:\Temp -Recurse -Force -Include Bac*OutputPS C:\WINDOWS\system32> Get-ChildItem D:\Temp -Recurse -Force -Include Bac*     Directory: D:\Temp\GPO_backup\{C9C3DB4C-2E51-4201-B3C3-7C0F1ACECBE9} Mode                LastWriteTime         Length Name ----                -------------         ------ ---- -a----       24-11-2018     11:34           6215 Backup.xmlCommandWhen you use the wildcard character (*) at both the ends, file ...

Read More

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

Chirag Nagrekar
Chirag Nagrekar
Updated on 23-Jan-2020 20K+ Views

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                LastWriteTime         Length Name ----                -------------         ------ ---- -a----       24-11-2018     11:34           6215 Backup.xml -a----       24-11-2018     11:34       ...

Read More

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

Chirag Nagrekar
Chirag Nagrekar
Updated on 23-Jan-2020 972 Views

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 783 Views

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 use Depth pararmeter in Get-ChildItem PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 23-Jan-2020 3K+ Views

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 specify –Depth parameter, no need to add –Recursion parameter. It will automatically set the depth level.Get-ChildItem D:\Temp\ -Depth 1OutputPS C:\WINDOWS\system32> Get-ChildItem D:\Temp\ -Depth 1     Directory: D:\Temp Mode                LastWriteTime         Length Name ----             ...

Read More

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

Chirag Nagrekar
Chirag Nagrekar
Updated on 23-Jan-2020 1K+ Views

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 ----                -------------         ------ ---- d-----       13-12-2019     09:52                GPO_backup d-----       24-11-2018     11:31                LGPO -a----       07-05-2018     23:00     ...

Read More

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

Chirag Nagrekar
Chirag Nagrekar
Updated on 23-Jan-2020 8K+ Views

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 ----                -------------         ------ ---- d-----       13-12-2019     09:52                GPO_backup d-----       24-11-2018     11:31                LGPO -a----       07-05-2018     23:00     ...

Read More

Which methods are supported by Get-ChildItem in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 22-Jan-2020 475 Views

There are methods or functions which are useful for directories and file operations.Methods for the directory.TypeName: System.IO.DirectoryInfo Name                      MemberType ----                      ---------- Create                    Method CreateObjRef              Method CreateSubdirectory        Method Delete                    Method EnumerateDirectories      Method EnumerateFiles            Method EnumerateFileSystemInfos  Method Equals                    Method ...

Read More

How to list the directory content in PowerShell?

Chirag Nagrekar
Chirag Nagrekar
Updated on 22-Jan-2020 40K+ Views

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 run outside of this directory then the path of the directory should be provided. This is called the absolute path.PS C:\> Get-ChildItem D:\Temp\CommandWhen this command is run directly within the directory then simply run this command. This is called a relative path.PS D:\Temp> Get-ChildItem OutputDirectory: D:\Temp Mode       ...

Read More
Showing 351–360 of 391 articles
« Prev 1 34 35 36 37 38 40 Next »
Advertisements