About 1,600,000 results
Open links in new tab
  1. PowerShell script to check an application that's locking a file?

    Jan 10, 2016 · This could help you: Use PowerShell to find out which process locks a file. It parses the System.Diagnostics.ProcessModuleCollection Modules property of each process and it looks for the file path of the locked file: Simplified:

  2. How to know which processes are using the specified file

    Jul 9, 2017 · How to Find Out Which Windows Process is Using a File (Process Explorer) 2.PowerShell method: Write-Warning "File or directory does not exist." $LockingProcess = CMD /C "openfiles /query /fo table | find /I ""$FileOrFolderPath""" Write-Host $LockingProcess. 3.

  3. How to check if file is being used by another process - Powershell

    Feb 22, 2012 · Currently I am using the function mentioned below, which is not ideal as the script takes about 5 - 10 minutes to retrieve a value. write-host (getDateTime) "[ACTION][FILECHECK] Checking if" $filePath "is locked" if(Get-Content $filePath | select -First 1) write-host (getDateTime) "[ACTION][FILEAVAILABLE]" $filePath. return $true. else.

  4. How to use PowerShell Get-Content to Read a File - LazyAdmin

    Feb 7, 2023 · To view the results of the newly created file, we can use the Get-Content cmdlet. You only need to specify the path to the file to start reading its contents of it: If we store the result of Get-Content in a variable, then we can see that PowerShell stores the results in an array.

  5. Powershell - Check if file is in use - Stack Overflow

    Aug 26, 2010 · If you want to check any file, I'm sure you can adapt this C# logic in powershell with your own function: stackoverflow.com/questions/876473/… Also, if you want to go further and gain access to a locked file you can try unlocking it also: msdn.microsoft.com/en-us/library/system.io.filestream.aspx.

  6. How to Check if File Exists in PowerShell — LazyAdmin

    Sep 30, 2024 · In this article, we will look at the different methods of how you can check if a file exists and how to use it in your scripts. There are basically two methods in PowerShell to check for the existence of a file. The recommended way is to use the Test-Path cmdlet, and another option is to use the Get-ChildItem cmdlet.

  7. Working with files and folders - PowerShell | Microsoft Learn

    Oct 18, 2023 · Navigating through PowerShell drives and manipulating the items on them is similar to manipulating files and folders on Windows disk drives. This article discusses how to deal with specific file and folder manipulation tasks using PowerShell. You can get all items directly within a folder using Get-ChildItem.

  8. Find which Windows process has file in use

    Jul 28, 2021 · Windows has a built-in way to see which processes are actively using a file or directory, using the Resource Monitor. To open the Resource Monitor, you can simply hit the Windows Key and search for it. It can also be found in the Task Manager’s Performance tab.

  9. How to Write and Run Scripts in the Windows PowerShell ISE

    Mar 27, 2025 · On the toolbar, click New, or on the File menu, click New. The created file appears in a new file tab under the current PowerShell tab. Remember that the PowerShell tabs are only visible when there are more than one. By default a file of type script (.ps1) is created, but it can be saved with a new name and extension.

  10. PowerShell Write to File [With Examples] - SPGuides

    Apr 17, 2025 · The script below will add static text to the file using the Out-File cmdlet. "This is a static text written to the file using Out-File." | Out-File -FilePath "C:\Bijay\example.txt" Once you execute the script, it creates the text file and adds its content. See the screenshot for reference.

  11. Some results have been removed
Refresh