Exchange/Office365自动处理脚本:常用函数(一)-创新互联-古蔺大橙子建站
RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
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,$password
return $cred
}
function skypeaccountname
{
$account="skypeaccountname@genomics.cn" 
$password = ConvertTo-SecureString "Account Password" -asplaintext -force
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$password
return $cred
}
function o365accountname
{
$account="O365accountname@genomics.cn" 
$password = ConvertTo-SecureString "Account Password" -asplaintext -force
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$password
return $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 $cred
Import-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 $so
Import-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" -AllowRedirection
Import-PSSession $exchangeSession -AllowClobber
}

示例为连接国际版Office365。
如连接21Vianet,使用_ConnectionUri_值:https://partner.outlook.cn/PowerShell
如连接德国Office 365,使用_ConnectionUri_值:https://outlook.office.de/powershell-liveid/

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章名称:Exchange/Office365自动处理脚本:常用函数(一)-创新互联
URL网址:http://scgulin.cn/article/gphcs.html