Handling files
Before we can work with files, we need to be able to find them, and understand how PowerShell works with hierarchical data structures such as filesystems.
A brief note about PSProviders and PSDrives
PowerShell connects to data structures through software called providers. These allow PowerShell to present a data structure as a filesystem (including the filesystem). On Windows, this allows us to search for and manipulate objects in the Registry and the Certificate Store as if they were files. Arguably, it is less useful on Linux. Let’s have a look. Run this:
Get-PSProvider
You should see a list of providers and associated drives. We can connect to the associated drive with the Set-Location
cmdlet:
Set-Location Env:
Note we have to use the name of the drive, not the name of the provider, and we need to follow it with a colon.
Once in the data structure, we can use Get-ChildItem
to search for objects, as in the following screenshot, which lists...