Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Supress Module Warning #48

Open
bernddausch opened this issue Jul 26, 2018 · 8 comments
Open

Supress Module Warning #48

bernddausch opened this issue Jul 26, 2018 · 8 comments

Comments

@bernddausch
Copy link

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

@jnury
Copy link
Contributor

jnury commented Jul 26, 2018

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'

@bernddausch
Copy link
Author

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.

@jnury
Copy link
Contributor

jnury commented Jul 26, 2018

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

@bernddausch
Copy link
Author

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.

@jnury
Copy link
Contributor

jnury commented Jul 26, 2018

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

@bernddausch
Copy link
Author

bernddausch commented Jul 26, 2018 via email

@jnury
Copy link
Contributor

jnury commented Jul 26, 2018

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 ...

@bernddausch
Copy link
Author

bernddausch commented Jul 26, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants