For all folders in both local drive and OneDrive 365 Home, how to list all files containing certain words and output their full pathnames into either Excel or text file?

Sunny PA Wong 1 Reputation point
2024-10-02T12:54:03.0266667+00:00

For both local drive and OneDrive 365 Home, I need help to find all pdf files with

  1. names containing "ABC" and

file content containing certain text

The search results as follows:

Full pathname of each file

list format is either

Excel rows or

  lines in Text File.
  

I tried Powershell and followed Windows 11 Copilot suggestion which requires install of a module as follows

Install-Module -Name PSPDFKit -Scope CurrentUser

However, above command unfortunately did not install due to following error

Copyright (C) Microsoft Corporation. All rights reserved. Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows PS C:\Users\me> Install-Module -Name PSPDFKit -Scope CurrentUser NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\sunny\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PSPDFKit'. Try Get-PSRepository to see all available registered module repositories. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21 + ... $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex ception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Thanks in Advance! For both local drive and OneDrive 365 Home, I need help to find all pdf files with

names containing "ABC" and

file content containing certain text

The search results as follows:

Full pathname of each file

list format is either

Excel rows or

  lines in Text File.
  

I tried Powershell and followed Windows 11 Copilot suggestion which requires install of a module as follows

Install-Module -Name PSPDFKit -Scope CurrentUser

However, above command unfortunately did not install due to following error

Copyright (C) Microsoft Corporation. All rights reserved. Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows PS C:\Users\me> Install-Module -Name PSPDFKit -Scope CurrentUser NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\sunny\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PSPDFKit'. Try Get-PSRepository to see all available registered module repositories. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21 + ... $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex ception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Thanks in Advance!

OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,107 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,499 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 46,636 Reputation points
    2024-10-02T18:33:27.25+00:00

    First, check the basics:

    Get-PSRepository
    
      Name                      InstallationPolicy   SourceLocation
      ----                      ------------------   --------------
      PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2
    
    Find-Package nuget
    
      Name                           Version          Source           Summary
      ----                           -------          ------           -------
      NuGet                          1.3.3            PSGallery        Create Nuget repos, Register Repos, Manage Modules ...
    
    
    Find-Module pspdf
    
      Version    Name                                Repository           Description
      -------    ----                                ----------           -----------
      1.6        PsPdf                               PSGallery            Collection of tools for manipulating PDF documen...
    
    # the module isn't installed on my system, so no results
    get-module pspdf -ListAvailable
    

    Is the PSGallery in your list of repositories? Is NuGet installed on your machine? Can you find the pspdf module? Is the pspdf module installef on your system?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.