Technology Software

How to Use PowerShell to List All Office Docs

    • 1). Open Notepad and create a new document.

    • 2). Paste the following three PowerShell commands into that document:

      $Folder_To_Check = "abc"

      $Report_File_Location = "xyz"

      Get-Childitem -Path $Folder_To_Check -Recurse -include *.ppt, *.pptx, *.pptm, *.potx, *.potm, *.ppsx, *.ppam, *.ppsm, *.sldx, *.sldm, *.thmx, *.xls, *.xlsx, *.xlsm, *.xltx, *.xltm, *.xlsb, *.xlam, *.doc, *.docx, *.docm, *.dotx, *.dotm > $Report_File_Location

    • 3). Locate the first command. Replace "abc" with the name of the folder in which you want to find all .doc files. For example, to search a folder on your "C" drive named "Meetings," change the first command to read as follows:

      $Folder_To_Check = "C:\Meetings"

    • 4). Locate the second command. Replace "xyz" with the path to a text file where you would like to store the search results. For instance, to store the results in a text file named "results.txt" in a folder named "Search_Results" on your "C" drive, change the second command to read as shown below:

      $Report_File_Location = "C:\Search_Results\results.txt"

    • 5). Click "File" to display Notepad's drop-down menu. Click "Save As." The "Save As" window opens.

    • 6). Type xyz.ps1 in the "File Name" text box. Replace "xyz" with any name you like. For instance, to call it "Doc_Search," type "Doc_Search.ps1" in the text box. Click "Save." Notepad saves the document as a PowerShell file.

    • 7). Open Windows Explorer and locate that file. Double-click it. The PowerShell script runs and finds all office doc files in the folder that you specified in the script. It then stores the search results for the file you designated in the PowerShell script.



Leave a reply