'Retrieve Outlook info account from multi profile
I am working on an Outlook inventory powershel script (see also powershell calculated properties for multiple values)
This code work great, but only with the default Outlook profile. I need retrieve data from all Outlook profiles
Add-Type -assembly "Microsoft.Office.Interop.Outlook"
$Outlook = New-Object -comobject Outlook.Application
$namespace = $Outlook.GetNameSpace("MAPI")
$namespace.Accounts | Select-Object DisplayName, SmtpAddress, UserName, AccountType, ExchangeConnectionMode | Sort-Object -Property SmtpAddress | Format-Table
Part of solution is get Outlook profile list:
Get-childItem -Path "HKCU:Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
And run previous code against each profile obtained. Here is where my cry for help shows up :) How could this be done?
Solution 1:[1]
You can use Extended MAPI (C++ or Delphi only) to retrieve the IProfAdmin interface, loop through all profiles, and list all services.
If Extended MAPI is not an option, you can use the ProfMan library (I am its author, it comes with the distributable version of Redemption):
http://www.dimastr.com/redemption/profman_examples.htm#example1 :
'Enumerate and print the names of all services in all profiles
set Profiles=CreateObject("ProfMan.Profile")
for i = 1 to Profiles.Count
set Profile = Profiles.Item(i)
set Services = Profile.Services
Debug.Print "------ " & Profile.Name & " ------"
for j = 1 to Services.Count
Debug.Print Services.Item(j).ServiceName
next
next
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dmitry Streblechenko |