Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Faq ► FAQ - Windows cmd.exe Command-Prompt ► ««« »»»

Check if there is a file path via PowerShell?


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 !

EXAMPLE 1:

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"
True
PS C:\> test-path -path "C:\Windows\System64"
False
PS C:\>  


If an element is missing, the test-path returns "False" as the return value. Otherwise  "True"  


EXAMPLE 2:

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 
True
PS C \>
 
PS C: \>$profile
C:\Users\Nenad\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PS C:\>


These commands use "$profile", the automatic variable that points to the location for the profile, even if the profile does not exist.


EXAMPLE 3:

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
True
PS C:\> test-path -path "C:\Windows\*.ini2" -exclude *.txt2
False
PS C:\> 
 


Further helpful tips: ►  ... MS-Determines whether all elements of a path exist?







FAQ 43: Updated on: 4 July 2021 14:01 Windows
Windows-Console

Create multiple guest accounts on Windows 11, 10, 8.1, MS Server with commands?


It is very easy to create multiple guest accounts for guest users under Windows 11 / 10 / 8.1 / 7, or Windows Server by using command lines It is not only
Windows-Console

Use batch file to start multiple programs on Windows 11, 10...!


Start several programs at the same time via a batch file in order to save several clicks, is very popular on MS Windows 11, 10, desktop and server operating
Windows-Console

How do I force a logoff via command line, Windows 11, 10, 8.1, .. and MS Server?


The solution is very simple, to force that the logoff is carried out via the command line under Microsoft Windows 11 / 10 / 8.1 / 7 If some programs have
Windows-Console

Create bootable USB stick with Windows, but how?


Creating a bootable USB stick as an installation medium for Windows is no magic Everyone comes to this point and wants a solution that is very simple to
Windows-Console

Command line to change the drive label of a drive!


The solution with the cmd.exe is very easy to change the drive designation of a drive via command line on all MS Windows OS Under Windows, you can easily
Windows-Console

Query startup programs via the command line or PowerShell!


You can create a list of programs via the cmd.exe command line or via PowerShell, which are started when Windows starts You can easily identify the programs
Windows-Console

Get a computer's MAC address, command line?


The solution is very simple to find out a MAC address of a computer in the network Not only under MAC / Linux you can quickly find out the so-called MAC

»»

  My question is not there in the FAQ
Asked questions on this answer:
Keywords: windows, 11, 10, server, eleven, console, check, file, path, powershell, solution, command, folder, available, Questions, Answers, Software




    

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + TraceRouteOK
  + GetWindowText
  + AutoHideMouseCursor
  + Desktop.Calendar.Tray.OK
  + OK.Its.Raining.Men
  + Run-Command
  + MagicMouseTrails
  + CpuFrequenz
  + MultiClipBoardSlots
  + PAD-s

Links:
ButtonOK.com

Home | Thanks | Contact | Link me | FAQ | Windows 2021 | Windows 10 | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2023 by Nenad Hrg softwareok.de • softwareok.com • softwareok.com • softwareok.eu
0.077


► Test the PC for several hours! ◄

► Double spaces replace in the text on Windows 11, 10, 8.1, ...! ◄

► What is a print server? ◄

This website uses cookies to ensure you get the best experience on our website more Infos & Privacy Policy
....