centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 273 forks source link

[apps::microsoft::sccm::local::plugin] mode site-status #3076

Closed ritouret closed 3 years ago

ritouret commented 3 years ago

Hello,

After last update of SCCM in version 2103, this mode is broken. I've installed the last centreon_plugins.exe 20210902 from today and i have this response now :

Use of uninitialized value in numeric eq (==) at (eval 36) line 1. Use of uninitialized value in numeric eq (==) at (eval 36) line 1. UNKNOWN: Command error: System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'. - at Microsoft.ConfigurationManagement.PowerShell.Provider.CMDriveProvider.Start(ProviderInfo providerInfo) - at System.Management.Automation.SessionStateInternal.NewProvider(ProviderInfo provider)

I don't know if it's the same cause for this issue : https://github.com/centreon/centreon-plugins/issues/2906 But it's not the same output messages.

Thanks

garnier-quentin commented 3 years ago

Could you execute the powershell directly ? You can get with --ps-display

garnier-quentin commented 3 years ago

Please execute it directly to see the result

ritouret commented 3 years ago

yes, there is the result :

System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'. at Microsoft.ConfigurationManagement.PowerShell.Provider.CMDriveProvider.Start(ProviderInfo providerInfo) at System.Management.Automation.SessionStateInternal.NewProvider(ProviderInfo provider)

garnier-quentin commented 3 years ago

Could you try to execute following powershell code:

$modulePath = ${env:SMS_ADMIN_UI_PATH}
$modulePath = $modulePath.Substring(0, $modulePath.lastIndexOf("\"))
$module = $modulePath + "\ConfigurationManager.psd1"
Import-Module $module
$providers = Get-PSProvider | Where {$_.Name -match "CMSite" }
ritouret commented 3 years ago

PS C:\Windows\system32> $modulePath = ${env:SMS_ADMIN_UIPATH} $modulePath = $modulePath.Substring(0, $modulePath.lastIndexOf("\")) $module = $modulePath + "\ConfigurationManager.psd1" Import-Module $module $providers = Get-PSProvider | Where {$.Name -match "CMSite" }

ritouret commented 3 years ago

(pas de message d'erreur)

garnier-quentin commented 3 years ago

could you provide the result of:

Get-PsProvider
ritouret commented 3 years ago

PS C:\Windows\system32> Get-PsProvider

Name Capabilities Drives


Alias ShouldProcess {Alias}
Environment ShouldProcess {Env}
FileSystem Filter, ShouldProcess, Credentials {C, D, E, F...}
Function ShouldProcess {Function}
Registry ShouldProcess, Transactions {HKLM, HKCU}
Variable ShouldProcess {Variable}

garnier-quentin commented 3 years ago

There is no CMSite provider... Is it working for you:

New-PSDrive -Name SCCMDrive -PSProvider "CMSite" -Root $env:COMPUTERNAME -Description "SCCM Site"
ritouret commented 3 years ago

Unfortunatly no :

PS C:\Windows\system32> New-PSDrive -Name SCCMDrive -PSProvider "CMSite" -Root $env:COMPUTERNAME -Description "SCCM Site" New-PSDrive : Cannot find a provider with the name 'CMSite'. At line:1 char:1

garnier-quentin commented 3 years ago

Following is working ?

New-PSDrive -Name SCCMDrive -PSProvider "AdminUI.PS.Provider\CMSite" -Root $env:COMPUTERNAME -Description "SCCM Site"

So i need to set that value if it's empty.

ritouret commented 3 years ago

Sorry Quentin, another error :

PS C:\Windows\system32> New-PSDrive -Name SCCMDrive -PSProvider "AdminUI.PS.Provider\CMSite" -Root $env:COMPUTERNAME -Description "SCCM Site"

New-PSDrive : Cannot find a provider with the name 'AdminUI.PS.Provider\CMSite'. At line:1 char:1

garnier-quentin commented 3 years ago

It was working before ?

ritouret commented 3 years ago

The mode yes, it was working before the upgrade yesterday

ritouret commented 3 years ago

I asked to our expert who made the upgrade to ask to Microsoft what happened to this Provider. I'll let you know. Thank you.

garnier-quentin commented 3 years ago

It was that line before the patch:

New-PSDrive -Name SCCMDrive -PSProvider "AdminUI.PS.Provider\CMSite" -Root $env:COMPUTERNAME -Description "SCCM Site"
ritouret commented 3 years ago

Same Error :

PS C:\Windows\system32> New-PSDrive -Name SCCMDrive -PSProvider "AdminUI.PS.Provider\CMSite" -Root $env:COMPUTERNAME -Description "SCCM Site" New-PSDrive : Cannot find a provider with the name 'AdminUI.PS.Provider\CMSite'. At line:1 char:1

garnier-quentin commented 3 years ago

I used a default provider if we don't find with Get-PSProvider. You can test:

$modulePath = ${env:SMS_ADMIN_UI_PATH}
$modulePath = $modulePath.Substring(0, $modulePath.lastIndexOf("\"))
$module = $modulePath + "\ConfigurationManager.psd1"
Import-Module $module

$providers = Get-PSProvider | Where {$_.Name -match "CMSite" }
if ($null -eq $providers -or $providers.Count -eq 0) {
        $providers = New-Object System.Collections.Generic.List[Hashtable];
        $item = @{}
        $item.Name = "AdminUI.PS.Provider\CMSite"
        $items.Add($item)
}
ritouret commented 3 years ago

Hello Quentin,

I've just tested and here is the result : Import-Module : Method not found: '!!0[] System.Array.Empty()'. At line:4 char:1

You cannot call a method on a null-valued expression. At line:11 char:9

garnier-quentin commented 3 years ago

Please test with last version: https://github.com/centreon/centreon-nsclient-build/releases/tag/20210910075442

ritouret commented 2 years ago

That's what i've done.

In the meantime, our expert has installed the Microsoft .NET 4.7.2 which is a required by SCCM 2103 for the ConfigurationManager PowerShell module : that was the problem.

It works fine except this new error : https://github.com/centreon/centreon-plugins/issues/3150