The solution is very simple to use a command in PowerShell to check whether a file path or folder path is available!
The solution is very simple with the test-path command, if you do not see the files in the standard Windows file explorer because it may be hidden or does not appear at all. Here is a solution that administrators on MS Windows 11, 10, ... MS Servers OS like to use to query the existence of certain folders, files and file types / file extensions!
To do this, start the Windows Powershell , or optionally PowerShell in the ColorConsole !
Query whether a directory exists!
The test-path -path command checks whether all elements are present in the path, ie the drive "C:\" and the main directory "Windows" and the subdirectory "System32" .
PS C:\> test-path -path "C:\Windows\System32"
PS C:\> test-path -path "C:\Windows\System64"
If an element is missing, the test-path returns "False" as the return value. Otherwise "True"
The layer command $ profile to test the path to the Windows PowerShell profile.
And querying the profile file ;-)
PS C \> test-path -path $profile -IsValid
PS C \>
PS C: \>$profile
These commands use "$profile", the automatic variable that points to the location for the profile, even if the profile does not exist.
With this command you can query certain file extensions whether they exist in the directory!
PS C:\> test-path -path "C:\Windows\*.ini" -exclude *.txt
PS C:\> test-path -path "C:\Windows\*.ini2" -exclude *.txt2
Further helpful tips: ► ... MS-Determines whether all elements of a path exist?
FAQ 43: Updated on: 4 July 2021 14:01