Invoke-DbaQuery in Powershell 7.2 not working

  • All the user profiles on my test server were deleted. Now, dbatools is not working. Invoke-DbaQuery runs fine in version 5.1. When I run it in 7.2.2, I get the following error message.

    Invoke-DbaQuery : The 'Invoke-DbaQuery' command was found in the module 'dbatools', but the module could not be loaded. For more information, run 'Import-Module dbatools'.

    When I run Import-Module dbatools, I get the following error message. Any idea how I can resolve this?

    Import-Module : Couldn't import dbatools library | Could not load file or assembly 'System.Management.Automation, Version=7.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.At line:1 char:1

    + Import-Module dbatools

    + ~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo : OperationStopped: (Couldn't import dba.the file specified.:String) [Import-Module], RuntimeException

    + FullyQualifiedErrorId : Couldn't import dbatools library | Could not load file or assembly 'System.Management.Automation, Version=7.2.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.,Microsoft.PowerShell.Commands.ImportModuleCommand

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • I think you may have correctly identified the problem...  Someone who is more knowledgeable about PoSh than I may have a bit of magic that I don't know about but I'm pretty sure that whoever is running the PoSH code is going to need privs on the server.  That might also be done in a "trusted" fashion using an AD group (Active Directory).

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Can you confirm that your DbaTools library is stored in the same location as found when running the following?

     

    $env:PSModulePath -split ';'

    (As I think some file locations differ between PoSh and PoSh Core.)

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply