FileSystem - PowerShell command help and examples

Provides access to files and directories. (FileSystem)


PROVIDER NAME 
    FileSystem 

DRIVES 
    C, D 

SYNOPSIS
Provides access to files and directories.
DESCRIPTION
The Windows PowerShell FileSystem provider lets you get, add, change, clear, and delete files and directories in Windows PowerShell. The FileSystem provider exposes Windows PowerShell drives that correspond to the logical drives configured on your computer, including drives mapped to network shares. For example, a computer with one floppy disk drive, one hard disk drive, and one mapped network shared directory might have drives named A, C, and Z. The FileSystem provider exposes Windows PowerShell drives that correspond directly to A, C, and Z, allowing you to reference these drives from within Windows PowerShell. For example, to reference drive C, you use C:, as shown in the following example: get-childitem c: The command returns all the contents on the C drive, including files and directories. When you reference a specific directory or file through the FileSystem provider, you must provide the information necessary to identify that directory or file. This means that, in some cases, you must provide a fully qualified name. A fully qualified name includes the drive name (along with a colon), any directory and subdirectory names, and the file name (when applicable). For instance, the following example shows the fully qualified name for the Shell.dll file, which is located in the System32 subdirectory of the Windows directory on the C drive: c:\windows\system32\shell.dll As you can see, each element of the fully qualified name is separated by a backslash (\). Windows PowerShell also allows you to use a forward slash (/) to be consistent with a variety of other shells. In some cases, you do not need to supply a fully-qualified name when referencing a file or directory. For example, if you want to access a file in your current working location, you need to provide only the file name. If your current working location is c:\windows, you can view a list of all the .dll files in that directory by using the following command: get-childitem *.dll If your working directory is something other than c:\windows, such as c:\program files\Windows PowerShell, your command might need to include the fully qualified name: get-childitem c:\windows\*.dll In some cases, you can use relative references to a location. If your working location is c:\windows, and you want to view a list of .dll files in the c:\windows\system32 directory, you can use the following command: get-childitem .\system32\*.dll The period before \system32 represents the current working location. In some situations, your current working location will be on a drive other than a FileSystem drive. If this is the case, you must always include the name of the target drive in your reference. For example, suppose that your current working location is the env: drive. To view the contents of the C drive, you would use the following command: get-childitem c: CAPABILITIES TASKS TASK: Navigating the File System

Examples

EXAMPLE 1
This command gets the current location: get-location The Get-Location cmdlet includes the functionality of commands like the cd command in the Windows Command Prompt and the pwd command in UNIX. For more information, type: get-help get-location
EXAMPLE 2
This command sets the current location: set-location C: TASK: Getting File and Directory Information
EXAMPLE 1
This command gets all the files and directories in the current directory: get-childitem By default, the Get-ChildItem cmdlet does not recurse. If files and folders are present in the current directory when you run this command, a System.IO.FileInfo object and a System.IO.DirectoryInfo object are returned.
EXAMPLE 2
This command gets all the files and directories in the current directory by using Get-ChildItem: get-childitem | where-object {!$_.psiscontainer} It pipes the results to Where-Object, which examines the PSIsContainer property and lets only the objects that are not (!) containers through the pipeline.
EXAMPLE 3
This command gets all the files and directories in the current directory by using Get-ChildItem. It pipes the results to Where-Object, which examines the PSIsContainer property and lets only the objects that are containers through the pipeline. get-childitem | where-object {$_.psiscontainer}
EXAMPLE 4
This command gets all the files and directories in the current directory by using Get-ChildItem: get-item -path a | format-list * It pipes the results to the Where-Object cmdlet, which examines the PSIsContainer property and lets only the objects that are containers through the pipeline.
EXAMPLE 5
This command uses the Get-Item cmdlet to get information about the Test.txt file: get-item -path test.txt | format-list * The Format-List cmdlet is used to display all the properties of the resulting object. TASK: Copying Files and Directories
EXAMPLE 1
This command copies the A.txt file from the C:\A directory to the C:\A\Bb directory: copy-item -path C:\a\a.txt -destination C:\a\bb\a.txt It overwrites files in the destination directory without prompting for confirmation.
EXAMPLE 2
This command copies all the files in the C:\A\Bb directory that have the .txt file name extension to the C:\A\Cc\Ccc\ directory: copy-item -path C:\a\bb\*.txt -destination C:\a\cc\ccc\ It uses the original names of the files. The command overwrites the existing files in the destination directory without prompting for confirmation.
EXAMPLE 3
Copies all the directories and files in the C:\a directory to the C:\c directory. If any of the directories to copy already exist in the destination directory, the command will fail unless you specify the Force parameter. copy-item -path C:\a\* -destination C:\c -recurse TASK: Moving Files and Directories
EXAMPLE 1
This command moves the C.txt file in the C:\A directory to the C:\A\Aa directory: move-item -path C:\a\c.txt -destination C:\a\aa The command will not automatically overwrite an existing file that has the same name. To force the cmdlet to overwrite an existing file, specify the Force parameter.
EXAMPLE 2
This command moves the C:\A directory and all its contents to the C:\B directory: move-item -path C:\a -destination C:\b You cannot move a directory when that directory is the current location. TASK: Managing File Content
EXAMPLE 1
This command appends the "test content" string to the Test.txt file: add-content -path test.txt -value "test content" The existing content in the Test.txt file is not deleted.
EXAMPLE 2
This command gets the contents of the Test.txt file and displays them in the console: get-content -path test.txt You can pipe the contents of the file to another cmdlet. For example, the following command reads the contents of the Test.txt file and then supplies them as input to the ConvertTo-HTML cmdlet: get-content -path test.txt | convertto-html
EXAMPLE 3
This command replaces the contents of the Test.txt file with the "test content" string: set-content -path test.txt -value "test content" It overwrites the contents of Test.txt. You can use the Value parameter of the New-Item cmdlet to add content to a file when you create it. TASK: Managing Security Descriptors
EXAMPLE 1
This command returns a System.Security.AccessControl.FileSecurity object: get-acl -path test.txt | format-list -property * For more information about this object, pipe the command to the Get-Member cmdlet. Or, see "FileSecurity Class" in the MSDN (Microsoft Developer Network) library at http://go.microsoft.com/fwlink/?LinkId=145718.
EXAMPLE 2
This command returns a System.Security.AccessControl.DirectorySecurity object: get-acl -path test_directory | format-list -property * For more information about this object, pipe the command to the Get-Member cmdlet. Or, see "DirectorySecurity Class" in the MSDN library at http://go.microsoft.com/fwlink/?LinkId=145736. TASK: Creating Files and Directories
EXAMPLE 1
This command creates the Logfiles directory on the C drive: new-item -path c:\ -name logfiles -type directory
EXAMPLE 2
This command creates the Log2.txt file in the C:\Logfiles directory and then adds the "test log" string to the file: new-item -path c:\logfiles -name log.txt -type file
EXAMPLE 3
Creates a file called Log2.txt in the C:\logfiles directory and adds the string "test log" to the file. new-item -path c:\logfiles -name log2.txt -type file -value "test log" TASK: Renaming Files and Directories
EXAMPLE 1
This command renames the A.txt file in the C:\A directory to B.txt: rename-item -path c:\a\a.txt -newname b.txt
EXAMPLE 2
This command renames the C:\A\Cc directory to C:\A\Dd: rename-item -path c:\a\cc -newname dd TASK: Deleting Files and Directories
EXAMPLE 1
This command deletes the Test.txt file in the current directory: remove-item -path test.txt
EXAMPLE 2
This command deletes all the files in the current directory that have the .xml file name extension: remove-item -path *.xml TASK: Starting a Program by Invoking an Associated File
EXAMPLE 1
The first command uses the Get-Service cmdlet to get information about local services. It pipes the information to the Export-Csv cmdlet and then stores that information in the Services.csv file. The second command uses Invoke-Item to open the Services.csv file in the program associated with the .csv extension: get-service | export-csv -path services.csv invoke-item -path services.csv DYNAMIC PARAMETERS -Encoding <Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding> Unknown The encoding type is unknown or invalid. The data can be treated as binary. String Uses the encoding type for a string. Unicode Encodes in UTF-16 format using the little-endian byte order. Byte Encodes a set of characters into a sequence of bytes. BigEndianUnicode Encodes in UTF-16 format using the big-endian byte order. UTF8 Encodes in UTF-8 format. UTF7 Encodes in UTF-7 format. ASCII Uses the encoding for the ASCII (7-bit) character set. Cmdlets Supported: Add-Content, Get-Content, Set-Content -Delimiter <System.String> Specifies the delimiter to use when reading the file. The default is "\n" (end of line). Cmdlets Supported: Get-Content -Wait <System.Management.Automation.SwitchParameter> Waits for content to be appended to the file. If content is appended, it returns the appended content. If the content has changed, it returns the entire file. When waiting, Get-Content checks the file once each second until you interrupt it, such as by pressing CTRL+C. Cmdlets Supported: Get-Content
NOTES
RELATED LINKS about_Providers C:\Windows>powershell get-help Function -full

Microsoft Windows [Version 10.0.19045.3693]
Copyright (c) 2023 Microsoft Corporation.

ColorConsole [Version 3.7.1000] PowerShell 2.0-Export

Windows 11, 10, 8.1, 8, 7 / Server 2022, 2019, 2016











Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



PowerShell: Provides access to files and directories.

HTTP: ... PS_Windows/en/FileSystem.htm
0.061
12856

Digital desktop clock free download full version for Windows 11, 10, ...!

Wo sind meine Downloads geblieben auf Windows 10/11!

When keystrokes in Explorer the search field is selected / jumps on?

So führen Sie eine App als anderer Benutzer in MS Windows 11/10 aus!

After Windows 10 Update no CD / DVD drive in MS-Explorer!

Windows 10 or 11 version and build number on the desktop!



(0)