1. Tất cả các công cụ PowerShell có sẵn trên Windows XP SP3, VISTA SPx, Windows 7, Windows Server 2003 SPx, windows 2008 R2 trước đây dùng kết nối với Live@edu đều không dùng kết nối với Office 365 được.Live@edu đều không dùng kết nối với Office 365 được.
2. Cần phải cài Windows PowerShell and the .NET Framework 3.5.1 enabled.
3. Cần phải cài Microsoft Online Services Sign-in Assistant phiên bản 7.0 hoặc Beta.
hãy download và cài đặt vào máy dùng PowerShell từ link Microsoft Download Center:
Microsoft Online Services Sign-In Assistant BETA – 32 bit/64 bit version //www.microsoft.com/en-us/download/details.aspx?id=39267 64 bit version //www.microsoft.com/en-us/download/details.aspx?id=39267
4. Cần phải download và cài Microsoft Online Services Module for Windows PowerShell:
hãy download và cài đặt vào máy dùng Powershell từ link Microsoft Download center:
Microsoft Online Services Module for Windows PowerShell [32-bit version]//go.microsoft.com/fwlink/p/?linkid=236298//go.microsoft.com/fwlink/p/?linkid=236298
Microsoft Online Services Module for Windows PowerShell [64-bit version] //go.microsoft.com/fwlink/p/?linkid=236297 //go.microsoft.com/fwlink/p/?linkid=236297
5. Các tài liệu hướng dẫn sử dụng Windows PowerShell để quản lý Office 365:
//technet.microsoft.com/en-us/library/jj151815.aspx
6. Sau đây là 3 phương thức kết nối PowerShell tới Office 365 bằng lệnh khi đã cài 2 phần mềm PowerShell:
Bấm vào: Start > All Programs > Microsoft Online Services [Folder] and select Microsoft Online Services Module for Windows PowerShell
hoặc Windows Azure Active Directory > Windows Azure Active Directory Module for Windows PowerShell
Phương thức 1:
Cách dùng kết hợp cả hàm cũ và mới của PowerShell để kết nối Office 365 [O365]:
Chép/ dán hoặc gõ lệnh sau:
$LiveCred = Get-CredentialConnect-MSOLservice –Credential $livecred$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirectionImport-PSSession $Session
Connect-MSOLservice –Credential $livecred
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
Phương thức 2:
Cách dùng lệnh chuẩn của Office 365 [O365] để kết nối thông qua Microsoft Online Service Module for Windows PowerShell [MOSMWP] : MOSMWP] :
Import-Module MSOnline$Creds = Get-CredentialConnect-MsolService –Credential $Creds
$Creds = Get-Credential
Connect-MsolService –Credential $Creds
Phương thức 3:
Cách dùng hàm kết hợp giữa O365 và hàm chuẩn PowerShell để kết nối :
Import-module msonlineConnect-MSOLservice$LiveCred = Get-Credential$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirectionImport-PSSession $Session
Connect-MSOLservice
$LiveCred =
Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
Ghi chú:
Các lệnh cũ dưới đây chỉ dùng được với Exchange Online và là phiên bản chỉ dùng ở Live@edu, chúng ta sẽ loại bỏ cách dùng đó.
Lệnh dùng Windows PowerShell 2.0 kết nối Exchange Online của Live@edu:
$LiveCred = Get-Credential$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirectionImport-PSSession $Session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
7. Lưu ý khi lần đầu cài Microsft PowerShell và chạy trên máy PC mới:
- Gõ lệnh trên màn PowerShell / cmdlet / cmdDOS :
Get-PSSnapin
- Gõ lệnh kiểm tra quyền chạy WinRM kết nối tới Office 365 [O365]:WinRM kết nối tới Office 365 [O365]:
net start winrmwinrm get winrm/config/client/auth
winrm get winrm/config/client/auth
- Gõ lệnh cấu hình lại quyền chạy winrm [nếu kết quả báo: Basic=false]:
winrm set winrm/config/client/auth @{Basic=”true”}
- Một số trường hợp đặc biệt, máy PC của bạn đang join domain và bị Global domain ngăn cản bằng các Policy domain hãy gõ lệnh sau để thiết lập quyền kết nối và điều khiển Office 365 bằng PowerShell:
Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy Unrestricted
- Nếu là bị GPO hạn chế quyền restricted policy hãy gõ lệnh sau:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy unrestricted -force
- Thêm vào đó 4 dòng lệnh sau:
Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy unrestricted -force
Set-ExecutionPolicy -Scope MachinePolicy -ExecutionPolicy unrestricted -force
Set-ExecutionPolicy -Scope UserPolicy -ExecutionPolicy unrestricted -force
Set-ExecutionPolicy -Scope Process -ExecutionPolicy unrestricted -force
8. Thêm tài khoản riêng hỗ trợ cho Admin quản lý tài khoản hoặc cho phép Powershell kết nối Office 365
Phải dùng tài khoản Administrator và truy cập vào “Organization Management” trong Exchange Control Panel [ECP]“Organization Management” trong Exchange Control Panel [ECP]
- Chọn Manage My Organization > Roles & Auditing > Administrator Roles. Manage My Organization > Roles & Auditing > Administrator Roles.
- bấm “Organization Management” > xem chi tiết sau đó thêm địa chỉ email vào “Member” > SaveOrganization Management” > xem chi tiết sau đó thêm địa chỉ email vào “Member” > Save
Tham khảo vai trò người quản lý: //help.outlook.com/vi-vn/140/ee441216.aspx //help.outlook.com/vi-vn/140/ee441216.aspx
9. Cách dùng lệnh PowerShell reset password hàng loạt tài khoản trên Office 365:
1. Tạo file ResetPassword_PS_Office365.CSV bằng Notepage hoặc Excel có cấu trúc như sau:
[có 2 cột: EmailAddresses và NewPassword].
2. Dùng Windows Azure Active Directory Module for Windows PowerShell gõ lệnh sau để chạy:
$LiveCred = Get-CredentialConnect-MSOLservice –Credential $livecred$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirectionImport-PSSession $Session
Connect-MSOLservice –Credential $livecred
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri //ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $SessionImport-Csv C:\Projects\ps1\ResetPassword_PS_Office365.csv|%{Set-MsolUserPassword –userPrincipalName $_.EmailAddresses -NewPassword $_.NewPassword -ForceChangePassword $false}
3. Kết quả đúng sẽ có màn hình hiển thị sau:
Chúc các Quản trị mạng dịch vụ tại các Trường
sử dụng thành thạo và ổn định hệ thống Office 365 !