Skip to content

Instantly share code, notes, and snippets.

@mardahl
Created December 18, 2020 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mardahl/636bc9ee0a0feacd61d19b9d3274d0d6 to your computer and use it in GitHub Desktop.
Save mardahl/636bc9ee0a0feacd61d19b9d3274d0d6 to your computer and use it in GitHub Desktop.
Script to export a list of all Outlook profiles attached to a user in Windows - can be run as login script
#Define central storage for the log files to be collected.
#Make sure all users that run this script have write permissions on this share
$logFile = "\\fileserver.domain.local\share\$($env:USERNAME)_OutlookAccounts.csv"
#Testing for Outlook 2013 and newer
If (Test-Path 'hkcu:\Software\Microsoft\Office\15.0\Outlook\Profiles') {
$regPath = 'hkcu:\Software\Microsoft\Office\15.0\Outlook\Profiles\*\9375CFF0413111d3B88A00104B2A6676\*'
}elseif(Test-Path 'hkcu:\Software\Microsoft\Office\16.0\Outlook\Profiles'){
$regPath = 'hkcu:\Software\Microsoft\Office\16.0\Outlook\Profiles\*\9375CFF0413111d3B88A00104B2A6676\*'
}else{
#Outlook not found - terminating
exit
}
#Exporting results in CSV format
Get-ItemProperty $regPath | Where{$_.'Account Name' -notmatch 'Outlook Address Book|Outlook Data File'} | Select @{n='Computer Name';e={$env:COMPUTERNAME}},@{n='User Name';e={$env:USERNAME}}, 'Account Name' | Export-Csv $logFile -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment