Office 365

Retrieving Office 365 message center using PowerShell

Posted on Updated on

How to Retrieving Office 365 message center Information using PowerShell

Quick handy script to do that, and you can take the output to write it in CSV file or import it in SharePoint List, or store it in any other repository

1. You need to download Office 365 Service Communications PowerShell Module from Get Hub
https://github.com/mattmcnabb/O365ServiceCommunications

2. Download the library, and un-zip the file
3. Now you will need to relocate the module files, you should find it in this paths
C:\Users\Administrator\Downloads\O365ServiceCommunications-master\O365ServiceCommunications-master\O365ServiceCommunications


Import-Module C:\Users\Administrator\Downloads\O365ServiceCommunications-master\O365ServiceCommunications-master\O365ServiceCommunications
# Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files (x86)\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files (x86)\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
# Specify tenant admin"
$User = "tenant.admin@company.onmicrosoft.com"
$Pass = "password"
$cred = New-Object System.Management.Automation.PSCredential($User,(ConvertTo-SecureString $Pass -AsPlainText -Force));
# gather events from the Service Communications API
$MySession = New-SCSession -Credential $cred
$Events = Get-SCEvent -EventTypes Message -PastDays 100 -SCSession $MySession |
Select-Object Id, Title, StartTime, Service, EventType, Status, @{n='Message';e={$_.messages[0].messagetext}}
foreach ($Event in $Events)
{
$Event.Id
$Event.Title
$Event.StartTime
$Event.Message
$Event.Service
$Event.EventType
$Event.Status
}
Write-Host "Completed!"

Advertisements

PowerShell for Show documents in Delve and in the Discover view in OneDrive for Business

Posted on Updated on

Delve is relatively still young baby for Microsoft.

Recently we have a requirement to enable the option of Show documents in Delve and in the Discover view in OneDrive for Business.

This can be done easily via a GUI like below

Go to App lancher and pick Delve –> Select Feature settings –> then enable Show documents in Delve and in the Discover view in OneDrive for Business

 

to do this via script, please copy and paste this in your PowerShell ISE and run it.

Pre-requistes

  1. Windows Internet Explorer
  2. You have to login at least 1 time through portal.office.com because the script will use your existing credentials


#Deactivate Delve Simulator
$ie = New-Object -COMObject InternetExplorer.Application
$jsonlink = "https://eur.delve.office.com/"
try{
#You can replace your the variable below with a static name, but her it logs with your current windows credentials
$searcher = [adsisearcher]"(samaccountname=$env:USERNAME)"
$mail = $searcher.FindOne().Properties.mail
$userName =$mail.replace("@","_").replace(".","_")
#Navigate to your download file/location
Write-host "Processing Request for: " $user.UPN
$ie.visible = $true
$ie.Navigate($jsonlink)
while($ie.Busy){Sleep 4}
while($ie.Document.location.href -like '*login.microsoftonline.com/*'){
(
$ie.document.IHTMLDocument3_getElementsByTagName("table") | Where-Object{$_.Id -eq $userName} | select -First 1).click()
Sleep 4
}
Write-Host "Ensure you are in the Delve Screem ..." -ForegroundColor Yellow
#[void](Read-Host 'Press Enter to continue after login ' -ErrorAction SilentlyContinue)
#Navigate to Properties
$ie.document.IHTMLDocument3_getElementById("O365_MainLink_Settings").click()
Sleep 4
#Open Settings
($ie.document.IHTMLDocument3_getElementsByTagName("a") | Where-Object{$_.className -eq "o365cs-settings-deeplink wf-size-x12 ms-fcl-ns o365button"} | select -First 1).click()
Sleep 4
##Switch Value
$checkBox =$ie.document.IHTMLDocument3_getElementById("enableDocumentsCheckbox")
$oldValue = $checkBox.value
if($oldValue -eq "on" -or $oldValue -eq "off")
{
$checked = $checkBox.click()
}
Sleep 2
#$newValue = $ie.document.IHTMLDocument3_getElementById("enableDocumentsCheckbox").value
##Submit
Sleep 1
($ie.document.IHTMLDocument3_getElementsByTagName("button") | Where-Object{$_.className -eq "SharingActivityPanel-module_button_delve"} | select -First 1).click()
##Refresh
Sleep 4
$ie.document.location = $ie.document.location
write-host "Done Successfully Delve Flag Switched"
}
catch [System.Exception]{
write-host "Failed, Try Again" $_.Exception
}
finally {
while($ie.Busy){Sleep 1}
$ie.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie)
}