确定是否已经成功调用connect-msolservice [英] Determine if connect-msolservice has already been successfully called

查看:49
本文介绍了确定是否已经成功调用connect-msolservice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PowerShell编写Office 365辅助工具,我有一个简单的问题,我找不到答案.如何判断由Connect-MsolService创建的连接是否存在并处于活动状态?肯定有某种方法可以知道,因为其他cmdlet可以检查,我只是不知道那是什么,而且我没有运气找到它.

I am writing an Office 365 assistance tool in PowerShell and have what I think is a simple question I can't find the answer to. How can I tell if a connection as created by Connect-MsolService is present and active? There must be some way to know because the other cmdlets can check, I just don't know what that way is and I'm not having luck finding it.

推荐答案

Connect-MsolService连接后返回一个对象,据我所知没有添加新变量.也许您可以通过运行模块命令之一并基于命令的执行结果来确定它:

Connect-MsolService return an object once connected, and as far as I can see doesn't add new variables. Maybe you can determine that by running one of the module commands and base it on the execution result of the command:

Get-MsolDomain -ErrorAction SilentlyContinue

if($?)
{
    "connected"
}
else
{
    "disconnected"
}

这篇关于确定是否已经成功调用connect-msolservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆