[英]Check if Microsoft services connected PowerShell
I have a script that uses three modules (Connect-MsolService, Connect-MicrosoftTeams, and Connect-ExchangeOnline).我有一个使用三个模块(Connect-MsolService、Connect-MicrosoftTeams 和 Connect-ExchangeOnline)的脚本。 I often run this script multiple times in a row.我经常连续多次运行这个脚本。 I want the script to be able to initiate the connection, but I don't want to have to connect each time.我希望脚本能够启动连接,但我不想每次都连接。 Other than asking the user if they've already connected, is there a way to test if a connection exists and is logged in?除了询问用户是否已经连接之外,有没有办法测试连接是否存在并已登录? The best I can come up with is searching for an admin that will always exist, if the return is null then connect but if anything is returned it is known a connection already is initiated.我能想到的最好的方法是搜索一个永远存在的管理员,如果返回是 null 然后连接,但如果返回任何内容,则知道连接已经启动。
Is there a simple way to do something like:有没有一种简单的方法来做类似的事情:
if(!isConnectedtoMicrosoftTeams){
Connect-MicrosoftTeams
}
Thank you!谢谢!
Connect services using access token.使用访问令牌连接服务。 This way you no need to promt for login.这样您就无需提示登录。 In this case also if return is null script should call the connect function to re generate new session.在这种情况下,如果返回 null 脚本应该调用连接 function 以重新生成新的 session。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.