Created
December 18, 2020 16:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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