Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing cmdlets with powershell 7 #8768

Closed
danpousson opened this issue Feb 20, 2023 · 14 comments
Closed

missing cmdlets with powershell 7 #8768

danpousson opened this issue Feb 20, 2023 · 14 comments
Labels
bugs life triage required New issue that has not been reviewed by maintainers

Comments

@danpousson
Copy link

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

most modules are not present:

example:
[no errorinvoke-dbaquery: The term 'invoke-dbaquery' is not recognized as a name of a cmdlet, function, script file, or executable program.](invoke-dbaquery: The term 'invoke-dbaquery' is not recognized as a name of a cmdlet, function, script file, or executable program.)

Steps to Reproduce

When I install dbatools on powershell 7, I only get these modules below:

get-command -Module dbatools | select Name
Attach-DbaDatabase
Detach-DbaDatabase
Get-DbaBuildReference
Get-DbaDbModule
Get-DbaRegisteredServer
Start-SqlMigration
Write-DbaDataTable
Select-DbaObject
Set-DbatoolsConfig

Is there a way to import all supported modules?
it looks like i see them [673 items] in: C:\Program Files\PowerShell\Modules\dbatools\1.1.145\functions

powershell install method: iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
dbatools versions tried: 1.1.141 - latest pre-release (i one by one removed and installed different versions)

  • I have local admin
  • I am running pwsh as Administator
  • I have tried this with -scope AllUsers and current user

Please confirm that you are running the most recent version of dbatools

yes: 1.1.145 (current version)

Other details or mentions

No response

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

PowerShell Host Version

Name Value


PSVersion 7.3.2
PSEdition Core
GitCommitId 7.3.2
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

SQL Server Edition and Build number

n/a

.NET Framework Version

.NET 7.0.2

@danpousson danpousson added bugs life triage required New issue that has not been reviewed by maintainers labels Feb 20, 2023
@danpousson
Copy link
Author

what modules should be available?

@wsmelton
Copy link
Member

wsmelton commented Feb 20, 2023

Once you import the module, all commands that are available to you can be found using:

Get-Command -Module dbatools

If you have issues running a command or receive an error that says a command is not available that should be you will need to troubleshoot why the module did not import into your session. You can use -Verbose parameter with Import-Module to possibly get more information. The other common issue is the module did not download correctly from the PowerShell Gallery due to Internet connectivity or AV software.

@danpousson
Copy link
Author

all i see are these:

get-command -Module dbatools | select Name
Attach-DbaDatabase
Detach-DbaDatabase
Get-DbaBuildReference
Get-DbaDbModule
Get-DbaRegisteredServer
Start-SqlMigration
Write-DbaDataTable
Select-DbaObject
Set-DbatoolsConfig

@wsmelton
Copy link
Member

The module did not import correctly or was prevented from importing completely.

@danpousson
Copy link
Author

thank you, i will investigate those last 2 comments

@wsmelton
Copy link
Member

If the import was completely successful there are 662 commands total available (at least on PowerShell 7.3.2 on Windows 10 OS)

image

@danpousson
Copy link
Author

so werid:

PS C:\Program Files\PowerShell\Modules\dbatools\1.1.145> import-module -name dbatools -Verbose

VERBOSE: Loading module from path 'C:\Program Files\PowerShell\Modules\dbatools\1.1.145\dbatools.psd1'.
VERBOSE: Importing cmdlet 'Select-DbaObject'.
VERBOSE: Importing cmdlet 'Set-DbatoolsConfig'.
VERBOSE: Importing alias 'Attach-DbaDatabase'.
VERBOSE: Importing alias 'Detach-DbaDatabase'.
VERBOSE: Importing alias 'Get-DbaBuildReference'.
VERBOSE: Importing alias 'Get-DbaDbModule'.
VERBOSE: Importing alias 'Get-DbaRegisteredServer'.
VERBOSE: Importing alias 'Start-SqlMigration'.
VERBOSE: Importing alias 'Write-DbaDataTable'.

PS C:\Program Files\PowerShell\Modules\dbatools\1.1.145>

@wsmelton
Copy link
Member

Delete the version and reinstall from the PowerShell Gallery

@danpousson
Copy link
Author

I'm able to recreate the issue in ps5.1 when adding -verbose to the import command as mentioned above.

Looks like AV maybe be blocking allcommands.ps1

looks like this file may be getting blocked:
This script contains malicious content and has been blocked by your antivirus software:
allcommands.ps1
C:\Program Files\PowerShell\Modules\dbatools\1.1.145\

&

C:\Program Files\WindowsPowerShell\Modules\dbatools\1.1.145\allcommands.ps1
that is my current path but it could vary based on install

@wsmelton
Copy link
Member

What AV are you using? We have another issue for one that don't think the AV software is going to fix.

@danpousson
Copy link
Author

too many:
Carbon Black (CB Defense)
Cylance Protect

I can ask them which one blocked it if you want.

@wsmelton
Copy link
Member

I can already tell you it will be Carbon Black.

Going to start tracking this in #8241 and I've pinned this issue so more users can be made aware.

@wsmelton wsmelton closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
@danpousson
Copy link
Author

update: FYI a Carbon Black agent update plus reboot fixed this for 5.1 & pwsh 7
AV issue

@script-it-check-it-quick-rewrite-it
Copy link

script-it-check-it-quick-rewrite-it commented Mar 28, 2023

update: FYI a Carbon Black agent update plus reboot fixed this for 5.1 & pwsh 7 AV issue

what version of CB fixed this for you? @danpousson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

3 participants