简体   繁体   English

检查微软服务是否连接 PowerShell

[英]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.

相关问题 使用PowerShell检查Windows服务状态 - Check Windows Services status using PowerShell Powershell - 检查一个或两个服务是否正在运行 - Powershell - Check if one or both Services are running Powershell 检查服务的脚本 - 启动服务 - 返回它已启动的状态 - Powershell script to check services - start services - return status that it is started 使用Powershell检查连接到路由器的活动IP或MAC - using powershell to check active IP's or MAC's connected to router 发出运行powershell命令以检查远程服务器服务状态的问题 - Issues running powershell command to check status of remote servers services 如何在PowerShell脚本中检查不同服务器上的不同服务? - How to check different services on different servers in powershell scripting? 使用PowerShell检查Microsoft Azure Active Directory应用程序中是否存在IdentifierUris - Check if IdentifierUris exists in Microsoft Azure Active Directory Application using PowerShell 如何使用Microsoft.TeamFoundation.PowerTools.PowerShell cmdlet查询Visual Studio Team Services(是VSO) - How to query Visual Studio Team Services (was VSO) using Microsoft.TeamFoundation.PowerTools.PowerShell cmdlets Powershell 停止具有依赖项的服务 - Powershell stopping services with dependencies Powershell Active Directory Web服务 - Powershell activedirectory web services
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM