mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Merge pull request #112 from Icinga:fix/wmi_permission_error_message
Improves msg for permssion error on CIM/WMI access
This commit is contained in:
commit
12acc8cc9c
3 changed files with 13 additions and 4 deletions
|
|
@ -38,6 +38,7 @@ Check Command configuration generated by Icinga for Windows 1.2.0 require Icinga
|
|||
* [#99](https://github.com/Icinga/icinga-powershell-framework/issues/99) Improves plugin output with different verbosity settings
|
||||
* [#100](https://github.com/Icinga/icinga-powershell-framework/issues/100), [#107](https://github.com/Icinga/icinga-powershell-framework/issues/107) Adds help for each Performance Counter Cmdlet, separates Cmdlets into single files, adds `Filter` option for `Show-IcingaPerformanceCounterCategories` and adds `Test-IcingaPerformanceCounterCategory` to test if a category exists on a system
|
||||
* [#108](https://github.com/Icinga/icinga-powershell-framework/issues/108) Adds function `Show-IcingaPerformanceCounterHelp` to fetch the help of a specific Performance Counter
|
||||
* [#111](https://github.com/Icinga/icinga-powershell-framework/issues/111) Improves error message on permission problems while accessing CIM/WMI objects including details on how to resolve them
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,14 @@ function Get-IcingaWindowsInformation()
|
|||
$ErrorMessage = $_.Exception.Message;
|
||||
$ErrorCode = $_.Exception.StatusCode;
|
||||
|
||||
if ([string]::IsNullOrEmpty($Namespace)) {
|
||||
$Namespace = 'root/cimv2';
|
||||
}
|
||||
|
||||
switch ($ErrorCode) {
|
||||
# Permission error
|
||||
2 {
|
||||
Exit-IcingaThrowException -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.CimInstance -CustomMessage $ClassName -Force;
|
||||
Exit-IcingaThrowException -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.CimInstance -CustomMessage ([string]::Format('Class: "{0}", Namespace: "{1}"', $ClassName, $Namespace)) -Force;
|
||||
};
|
||||
# InvalidClass
|
||||
5 {
|
||||
|
|
@ -55,10 +59,14 @@ function Get-IcingaWindowsInformation()
|
|||
$ErrorMessage = $_.Exception.Message;
|
||||
$ErrorCode = ($_.Exception.HResult -band 0xFFFF);
|
||||
|
||||
if ([string]::IsNullOrEmpty($Namespace)) {
|
||||
$Namespace = 'root/cimv2';
|
||||
}
|
||||
|
||||
switch ($ErrorName) {
|
||||
# Permission error
|
||||
'InvalidOperation' {
|
||||
Exit-IcingaThrowException -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.WMIObject -CustomMessage $ClassName -Force;
|
||||
Exit-IcingaThrowException -ExceptionType 'Permission' -ExceptionThrown $IcingaExceptions.Permission.WMIObject -CustomMessage ([string]::Format('Class: "{0}", Namespace: "{1}"', $ClassName, $Namespace)) -Force;
|
||||
};
|
||||
# Invalid Class
|
||||
'InvalidType' {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
[hashtable]$Permission = @{
|
||||
PerformanceCounter = 'A Plugin failed to fetch Performance Counter information. This may be caused when the used Service User is not permitted to access these information. To fix this, please add the User the Icinga Agent is running on into the "Performance Log Users" group and restart the service.';
|
||||
CacheFolder = "A plugin failed to write new data into the configured cache directory. Please update the permissions of this folder to allow write access for the user the Icinga Service is running with or use another folder as cache directory.";
|
||||
CimInstance = 'The user you are running this command as does not have permission to access the requested Cim-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch "root/cimv2" and add the permission "Remote enable".';
|
||||
WMIObject = 'The user you are running this command as does not have permission to access the requested Wmi-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch "root/cimv2" and add the permission "Remote enable".';
|
||||
CimInstance = 'The user you are running this command as does not have permission to access the requested Cim-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch for the Class/Namespace mentioned above and add the permission "Remote enable". Further details can be found here: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc771551(v=ws.11)';
|
||||
WMIObject = 'The user you are running this command as does not have permission to access the requested Wmi-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch for the Class/Namespace mentioned above and add the permission "Remote enable". Further details can be found here: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc771551(v=ws.11)';
|
||||
};
|
||||
|
||||
[hashtable]$Inputs = @{
|
||||
|
|
|
|||
Loading…
Reference in a new issue