在做Import-PSSession什么时如何避免所有不需要的控制台输出?我正在编写一个脚本来监视Exchange中的某些内容,它需要放入我们的监视系统并且只生成非常具体的输出,但每当我导入我的Exchange会话时它就会生成
警告:某些导入的命令名称包含未经批准的动词,这些动词可能会使其不易被发现.使用Verbose参数获取更多详细信息,或键入Get-Verb以查看已批准的动词列表.
我试过了:
$Session=(Import-PSSession(New-PSSession -ConfigurationName Microsoft.Exchange \
-ConnectionUri http://CasServer/PowerShell/ -Authentication Kerberos \
-Credential $Cred -AllowClobber -WarningAction:SilentlyContinue)
Run Code Online (Sandbox Code Playgroud)
它仍然显示不需要的文本.我也尝试过-ErrorAction:SilentlyContinue; 不起作用.
我想知道如何静态初始化字典列表 - 如下所示:
最初,我有一个这样的列表:
consumers = ['aserver.foo.com','anotherserver.foo.com',
'thirdserver.foo.com','lastserver.foo.com']
Run Code Online (Sandbox Code Playgroud)
但是我希望有一个我能解决的结构:
consumers = [
'aserver'{
'hostname'='aserver.foo.com',
'binddn'=masterbinddn,
'bindpw'=masterbindpw
},
'anotherserver'{
'hostname'='anotherserver.foo.com',
'binddn'=masterbinddn,
'bindpw'=masterbindpw
},
'athirdserver'{
'hostname'='athirdserver.foo.com',
'binddn'=targetbinddn,
'bindpw'=targetbindpw
},
'lastserver'{
'hostname'='lastserver.foo.com',
'binddn'=targetbinddn,
'bindpw'=targetbindpw
}
]
Run Code Online (Sandbox Code Playgroud)
这个想法是我可以做的事情:
for server in consumers:
do_something_to_server(server['hostname'], server['binddn'], server['bindpw'])
Run Code Online (Sandbox Code Playgroud)
我是在咆哮错误的树,还是只是遗漏了一些基本的东西?