JEA icon indicating copy to clipboard operation
JEA copied to clipboard

Supress Module Warning

Open bernddausch opened this issue 7 years ago • 8 comments

Hi,

we use JEA for our Monitoring Software to monitor Exchange server.

we create a module to load the Exchange pssnapins and add the module to ModulesToImport. This works, but the monitoring software put all console output to the monitoring Software.

When JEA Loads the Module, the Module generates a Warning and the warning ist on top of the console output, so i can't see the Interesting Output of the script.

Is there an option or can you add one, to supress the warning or set the WarningAction to silentlyContinue?

Regards,

Bernd

bernddausch avatar Jul 26 '18 08:07 bernddausch

Hello Bernd,

If the ExecutionPolicy parameter of your session configuration is NOT Restricted, you can create a PS1 script on your host (say C:\SetJEASessionPreferences.ps1) with your preferences:

# Disable warning messages
$WarningPreference = 'SilentlyContinue'

# Disable progress bars
$ProgressPreference = 'SilentlyContinue'

And then load this script at logon in your SessionConfiguration file:

# Scripts to run when applied to a session
ScriptsToProcess = 'C:\SetJEASessionPreferences.ps1'

jnury avatar Jul 26 '18 09:07 jnury

i have created the script, the execution policy is unrestricted. But I get the same Warning messages as bevore. The Warning comes when JEA Loads the Module.

bernddausch avatar Jul 26 '18 11:07 bernddausch

OK, you may try to load the module inside the script instead of the loading it with the session configuration.

jnury avatar Jul 26 '18 11:07 jnury

i have tried the import-module with -DisableNameChecking -WarningAction 0, but get the same warning message.

WARNING: The names of some imported commands from the module 'ExchangeConfig' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.

bernddausch avatar Jul 26 '18 11:07 bernddausch

Do you call Import-Module after $WarningPreference = 'SilentlyContinue' ?

jnury avatar Jul 26 '18 11:07 jnury

Yes, and if i start the Script in a normal Shell, there is no Warning message visible. But in the JEA Session the warning is shown.

Von: Julien Nury [email protected] Antworten an: PowerShell/JEA [email protected] Datum: Donnerstag, 26. Juli 2018 um 13:39 An: PowerShell/JEA [email protected] Cc: Bernd Dausch [email protected], Author [email protected] Betreff: Re: [PowerShell/JEA] Supress Module Warning (#48)

Do you call Import-Module after $WarningPreference = 'SilentlyContinue' ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

bernddausch avatar Jul 26 '18 11:07 bernddausch

The correct syntax would be Import-Module 'ExchangeConfig' -DisableNameChecking -WarningAction 'SilentlyContinue'

If it doesn't work, try Import-Module 'ExchangeConfig' 3>$null

If it still doesn't work, it may be a bug in the way snap-in modules are loaded ...

jnury avatar Jul 26 '18 11:07 jnury

I try both. But the Warning is still shown.

Von: Julien Nury [email protected] Antworten an: PowerShell/JEA [email protected] Datum: Donnerstag, 26. Juli 2018 um 13:51 An: PowerShell/JEA [email protected] Cc: Bernd Dausch [email protected], State change [email protected] Betreff: Re: [PowerShell/JEA] Supress Module Warning (#48)

The correct syntax would be Import-Module 'ExchangeConfig' -DisableNameChecking -WarningAction 'SilentlyContinue'

If it doesn't work, try Import-Module 'ExchangeConfig' 3>$null

If it still doesn't work, it may be a bug in the way snap-in modules are loaded ...

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

bernddausch avatar Jul 26 '18 12:07 bernddausch