Exchange/Office365 自动处理脚本:常用函数(一)
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,创建自定义函数脚本1,在C:\Users\当前登录用户名\Documents\WindowsPowershell下创建名称为Microsoft.PowerShell_profile.ps1 的文件2,
千家信息网最后更新 2026年11月02日Exchange/Office365 自动处理脚本:常用函数(一)
创建自定义函数脚本
1,在C:\Users\当前登录用户名\Documents\WindowsPowershell下创建名称为Microsoft.PowerShell_profile.ps1 的文件
2,打开Microsoft.PowerShell_profile.ps1,使用Powershell ISE添加以下函数
函数1:凭据
function exchangeaccountname{$account="exchangeaccountname@genomics.cn" $password = ConvertTo-SecureString "Account Password" -asplaintext -force$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$passwordreturn $cred}function skypeaccountname{$account="skypeaccountname@genomics.cn" $password = ConvertTo-SecureString "Account Password" -asplaintext -force$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$passwordreturn $cred}function o365accountname{$account="O365accountname@genomics.cn" $password = ConvertTo-SecureString "Account Password" -asplaintext -force$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$passwordreturn $cred}函数2:连接到Exchange 2010/2013 Server
function connectoExchange{$ConnectionUri = "http://cas01.domain.cn/PowerShell/","http://cas02.domain.cn/PowerShell/" #此处将链接修改为Exchange Cas$thisConnectionUri = $ConnectionUri | Get-Random$cred = exchangeaccountname #此处使用凭据函数echo $thisConnectionUri$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $thisConnectionUri -Authentication Kerberos -Credential $credImport-PSSession $Session -AllowClobber }}函数2:连接到Skype for Business 2015
function localskype{<#.Synopsis连接到skype for business 2015#>$cred= skypeaccountname #此处使用凭据函数$so = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true$Session = New-PSSession -ConnectionUri "https://sfbfe01.domain.cn/ocspowershell" -Credential $cred -SessionOption $soImport-PSSession $Session #此处将链接修改为skype前端}函数3:连接到Office365
function O365{<#.Synopsis连接到Office365#>import-module MSonline#输入Office365管理员账号和密码$credential = o365accountname #此处使用凭据函数Connect-MsolService -Credential $credential$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirectionImport-PSSession $exchangeSession -AllowClobber}示例为连接国际版Office365。
如连接21Vianet,使用_ConnectionUri_值:https://partner.outlook.cn/PowerShell
如连接德国Office 365,使用_ConnectionUri_值:https://outlook.office.de/powershell-liveid/
函数
凭据
链接
脚本
前端
名称
国际
国际版
密码
文件
用户
用户名
示例
管理员
账号
德国
登录
管理
输入
常用
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网科技深圳
重庆互联网络科技
奇酷互联网络科技
艾特科技互联网
凡科互联网科技
奇酷互联网络科技公司
互联网科技logo
深圳卡尔迅互联网科技有限公司怎么样
互联网之后的科技是什么
重庆威客帮互联网科技
互联网企业和科技型企业
互联网科技项目计划书材料类
健康食品互联网创新科技园项目
互联网保险科技创业
厦门江牛科技互联网
宇信科技在杭州互联网排第几
35岁以上互联网科技行业
互联网科技平台产品运营
好易买互联网科技
互联网金融金融科技
北京路客互联网科技有限公司
国智互联网科技
科技互联网公司装修
美国互联网黑科技
花神(南京)互联网科技有限公司
佛山市拉法互联网科技有限公司
怎样加入科技互联网
中国互联网有什么科技
众联互联网络科技
互联网科技企业文化