-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoft.PowerShell_profile.ps1
37 lines (30 loc) · 1.85 KB
/
Microsoft.PowerShell_profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Import-Module ActiveDirectory
Import-Module Microsoft.Online.SharePoint.PowerShell
Import-Module Microsoft.PowerShell.Management
#Import-Module 'C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.PowerShell.psd1'
#This PowerShell module allows you to connect to Exchange Online service.
#To connect, use: Connect-EXOPSSession -UserPrincipalName <your UPN>
#This PowerShell module allows you to connect Exchange Online Protection service too
#To connect, use: Connect-IPPSSession -UserPrincipalName <your UPN>
Set-Location ~
function Credentials(){
Add-Type -AssemblyName System.DirectoryServices.AccountManagement;
$Global:MyUPN = [System.DirectoryServices.AccountManagement.UserPrincipal]::Current.UserPrincipalName
$Global:UserCredential = Get-Credential -Credential $MyUPN
}
function Import-O365(){
Credentials
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
$O365ComplianceSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
$EOPO365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $O365Session
Import-PSSession $O365ComplianceSession
Import-PSSession $EOPO365Session
Connect-MsolService -Credential $UserCredential
#Connect-EXOPSSession -UserPrincipalName $MyUPN
#Connect-IPPSSession -UserPrincipalName $MyUPN
}
function prompt {
$Location = Get-Location
"$env:COMPUTERNAME : $env:USERNAME : $Location >"
}