2 FilesAndDirectoriesManageInWindows en
2 FilesAndDirectoriesManageInWindows en
Traverse directories.........................................1
How to manage an item in PS (file or directory)..............1
Text files content...........................................2
Compress and decompress items................................3
Traverse directories
When we want to refer to directories in PS, we will use the word
Location.
• Get-Location: to know the working directory. If we want to query
a different storage volume, we have to use the parameter -
PSDrive and the corresponding letter.
Get-Location -PSDrive C
• Set-Location path: to change the working directory
Set-Location C:\Users
1
The first one creates a directory and the second one creates a file
with the content “Hello in the file”. In addition, the second one
does not use optional parameter names. The value parameter is also
optional.
2
Compress and decompress items
This cmdlets provide us of a way to join in a file several files and
directories. The size of the generated file will be smaller than the
sum of the items compressed.
Compress-Archive file1, dir2, file2 -DestinationPath file.zip -
CompresionLevel Optimal
Expand-Archive -Path file.zip -DestinationPath directory
References:
Based on Rafael López García notes.