PoshCode Archive  Artifact [037432b91a]

Artifact 037432b91a79c6d2cfc2a4228b8ca22c51180a4be1fdc3fa85f8f8c85a0a3c40:

  • File Get-O365.ps1 — part of check-in [cf0bf71c7e] at 2018-06-10 13:46:27 on branch trunk — Just a simple function to show how to query Office 365 via powershell (user: Jeremy D Pavleck size: 833)

# encoding: ascii
# api: powershell
# title: Get-O365
# description: Just a simple function to show how to query Office 365 via powershell
# version: 0.1
# type: function
# author: Jeremy D Pavleck
# license: CC0
# function: Get-O365
# x-poshcode-id: 4831
# x-archived: 2014-01-29T05:09:17
# x-published: 2014-01-22T15:29:00
#
#
Function Get-O365 {
$cred = Get-Credential -Message "Your username is your email address for O365"
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://ps.outlook.com/powershell/" -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $session
$myMB = Get-Mailbox

Write-Host -ForegroundColor "Green" "Hello $($myMB.Name), your email address is $($myMB.WindowsEmailAddress), and your account was created $($myMB.WhenCreated)"
}