Skip to content

Instantly share code, notes, and snippets.

@pkothree
pkothree / CheckOwaPolicySetPhoto.ps1
Created January 4, 2021 08:03
Check if SetPhotoEnabled is true in the default policy
Get-OwaMailboxPolicy | FL name,SetPhotoEnabled
@pkothree
pkothree / ConnectToExchangeOnline.ps1
Last active January 4, 2021 08:00
Connect to Exchange Online
Install-Module ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline
@pkothree
pkothree / DowloadAttachments.ps1
Last active September 27, 2019 12:38
Dowload Attachements
$f.items | foreach{
$_.attachments|foreach{
Write-Host $_
$_.saveasfile((Join-Path $localpath $_.filename))
}
}
@pkothree
pkothree / PickOutlookFolder.ps1
Created September 27, 2019 12:12
Pick Outlook Folder
$f = $namespace.PickFolder()
@pkothree
pkothree / localpath.ps1
Created September 27, 2019 11:56
Variable with local path
$localpath = "C:\temp\"
@pkothree
pkothree / ConnectionToOutlook.ps1
Last active September 27, 2019 12:40
Establish a connection to Outlook
# Add assembly and create object to access Outlook
Add-type -assembly "Microsoft.Office.Interop.Outlook"
$olDefaultFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
$outlook = New-Object -comobject Outlook.Application
# Create namespace and get folders
$namespace = $outlook.GetNameSpace("MAPI")
$folders = $namespace.getDefaultFolder($olDefaultFolders::olFolderInBox)
# tests to see im connections work
@pkothree
pkothree / GetMailsFoldersUser.ps1
Last active September 27, 2019 12:40
Access Outlook with PowerShell
$namespace.CurrentUser # get the current user
$folders.items # shows all mails
$folders.folders # shows folders
@pkothree
pkothree / GetNamespace.ps1
Created July 26, 2019 10:16
Access Outlook with PowerShell
$namespace = $outlook.GetNameSpace("MAPI")
$folders = $namespace.getDefaultFolder($olDefaultFolders::olFolderInBox)
@pkothree
pkothree / ComObject.ps1
Created July 26, 2019 10:16
Access Outlook with PowerShell
$olDefaultFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
$outlook = New-Object -comobject Outlook.Application
@pkothree
pkothree / Add-Type.ps1
Created July 26, 2019 10:14
Access Outlook with PowerShell
Add-Type -assembly "Microsoft.Office.Interop.Outlook"