标签:col 简单 efault net rtt 结果 des ecif 调用
年也过完了,今天也该开工了,再来分享一个关于O365的脚本,之前分享过一个可以批量开启用户Onedrive for business的脚本,对于做一些迁移的工作来说会比较有帮助,今天再来分享一个如何获取用户开启Onedrive for business情况的脚本,在O365 admin portal推出报表的功能以前,这个脚本用来查看用户开启onedrive for business的情况是非常有帮助的,现在来说我们也可以通过这个脚本来查看实时的状态信息 大概的使用方法很简单,这个脚本是微软官方提供的,会调用一些SharePoint的API,本身逻辑不会很复杂
脚本的修改基本都是在脚本内部先修改完成的,所以运行的时候基本只要直接执行就可以了
之后可以看到运行结束了
之后去指定好的位置查看结果即可,可以看到目前开启了Onedrive for business的人是以下这些,和我目前环境中的情况是一致的
下边是具体的代码
# Specifies the URL for your organization's SPO admin service $AdminURI = "https://your organization name-admin.sharepoint.com" # Specifies the User account for an Office 365 global admin in your organization $AdminAccount = "global admin account" $AdminPass = "password for global admin account" # Specifies the location where the list of MySites should be saved $LogFile = 'C:\Users\youralias\Desktop\ListOfMysites.txt' # Begin the process $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $loadInfo3 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.UserProfiles") # Convert the Password to a secure string, then zero out the cleartext version ;) $sstr = ConvertTo-SecureString -string $AdminPass -AsPlainText –Force $AdminPass = "" # Take the AdminAccount and the AdminAccount password, and create a credential $creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($AdminAccount, $sstr) # Add the path of the User Profile Service to the SPO admin URL, then create a new webservice proxy to access it $proxyaddr = "$AdminURI/_vti_bin/UserProfileService.asmx?wsdl" $UserProfileService= New-WebServiceProxy -Uri $proxyaddr -UseDefaultCredential False $UserProfileService.Credentials = $creds # Set variables for authentication cookies $strAuthCookie = $creds.GetAuthenticationCookie($AdminURI) $uri = New-Object System.Uri($AdminURI) $container = New-Object System.Net.CookieContainer $container.SetCookies($uri, $strAuthCookie) $UserProfileService.CookieContainer = $container # Sets the first User profile, at index -1 $UserProfileResult = $UserProfileService.GetUserProfileByIndex(-1) Write-Host "Starting- This could take a while." $NumProfiles = $UserProfileService.GetUserProfileCount() $i = 1 # As long as the next User profile is NOT the one we started with (at -1)... While ($UserProfileResult.NextValue -ne -1) { Write-Host "Examining profile $i of $NumProfiles" # Look for the Personal Space object in the User Profile and retrieve it # (PersonalSpace is the name of the path to a user's OneDrive for Business site. Users who have not yet created a # OneDrive for Business site might not have this property set.) $Prop = $UserProfileResult.UserProfile | Where-Object { $_.Name -eq "PersonalSpace" } $Url= $Prop.Values[0].Value # If "PersonalSpace" (which we've copied to $Url) exists, log it to our file... if ($Url) { $Url | Out-File $LogFile -Append -Force } # And now we check the next profile the same way... $UserProfileResult = $UserProfileService.GetUserProfileByIndex($UserProfileResult.NextValue) $i++ } Write-Host "Done!"
可以看到里边有一些内容是需要修改的,比如admin url,账号密码,保存的位置等等,可以根据自己的实际情况进行修改,因为本身脚本需要修改的内容其实不多,所以也没花时间把他改成参数化的形式
使用PowerShell获取 O365 Onedrive for business列表
标签:col 简单 efault net rtt 结果 des ecif 调用
原文地址:http://blog.51cto.com/mxyit/2072138