timmcmic / DLConversionV2

MIT License
43 stars 9 forks source link

error with "start-collectOnPremSendAs" #174

Closed Arne-RFA closed 1 month ago

Arne-RFA commented 1 month ago

Running from W11 Pro 23H2, AD joined.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

After having much fun with modules, this seems to work to have the correct set installed and imported.

# cleanup graph1
Uninstall-Module Microsoft.Graph -AllVersions
# cleanup graph2
Get-InstalledModule Microsoft.Graph.* | ? Name -ne "Microsoft.Graph.Authentication" | Uninstall-Module -AllVersions
# cleanup graph1
Uninstall-Module Microsoft.Graph.Authentication -AllVersions
# cleanup EXO
Uninstall-Module -Name ExchangeOnlineManagement
# install graph auth 2.9.1
Install-Module -Name Microsoft.Graph.Authentication -RequiredVersion 2.9.1
# install DLConversionV2
Install-Module -Name DLConversionV2
# import module
Import-module DLConversionV2

With some mild obsfuscation and removal of the cert based auth parts to set variables

#Define on premises credentials.  (This assumes credential XMLs were previously defined.)
$adCred = import-cliXML "C:\TEMPDIR\DLMigrate\credentials\adCred.XML"
$exchangeOnPremCred = import-cliXML "C:\TEMPDIR\DLMigrate\credentials\adCred.XML"
#Define Active Directory information
$globalCatalogServer = "US-DCFILE01.nyc.clientdomain.com"
#Define EntraID Connect information
$aadConnectServer = "us-aadc.nyc.clientdomain.com"
# $Define Exchange On Premises information
$exchangeServer = "US-EXCH02.nyc.clientdomain.com"
#Define ms graph connection information
$msGraphTenantID="<GraphTenantID>"
$msGraphCertificateThumbprint="<GraphCertificateThumbprint>"
$msGraphApplicationID="<GraphApplicationID>"
#Define Exchange Online connection information
$exchangeOnlineCertificateThumbPrint="<exchangeOnlineCertificateThumbPrint>"
$exchangeOnlineOrganizationName="<OrganizationName>"
$exchangeOnlineAppID="<exchangeOnlineAppID>"
#Define additional parameters
$enableHybridMailFlow = $TRUE
$logFolderPath = "C:\TEMPDIR\DLMigrate\DLMigrations"
$dnNoSyncOU = "OU=DL-Migrate-NoSync,DC=nyc,DC=clientdomain,DC=com"
$groupSMTPAddress = "#NYCHelpDesk@clientdomain.com"

When I run the below

start-collectOnPremSendAs -logFolderPath $logFolderPath -exchangeServer $exchangeServer -exchangeCredential $exchangeOnPremCred

It errors out with

[6/4/2024 10:58:45 AM] - ================================================================================
[6/4/2024 10:58:45 AM] - START LOG FILE
[6/4/2024 10:58:45 AM] - ================================================================================
[6/4/2024 10:58:45 AM] - ********************************************************************************

ParameterName                Bound ParameterValue                           
-------------                ----- --------------                           
logFolderPath                 True C:\TEMPDIR\DLMigrate\DLMigrations            
exchangeServer                True US-EXCH02.nyc.clientdomain.com             
exchangeCredential            True System.Management.Automation.PSCredential
exchangeAuthenticationMethod False Basic                                    
retryCollection              False False                                    
bringMyOwnRecipients         False                                          
Verbose                      False                                          
Debug                        False                                          
ErrorAction                  False                                          
WarningAction                False                                          
InformationAction            False                                          
ErrorVariable                False                                          
WarningVariable              False                                          
InformationVariable          False                                          
OutVariable                  False                                          
OutBuffer                    False                                          
PipelineVariable             False                                          

[6/4/2024 10:58:45 AM] - ********************************************************************************
[6/4/2024 10:58:45 AM] - Calling New-PowerShellSession
[6/4/2024 10:58:45 AM] - ********************************************************************************

ParameterName         Bound ParameterValue                                 
-------------         ----- --------------                                 
Credentials            True System.Management.Automation.PSCredential      
Server                False                                                
PowershellSessionName  True ExchangePowershell                             
connectionURI          True https://US-EXCH02.nyc.clientdomain.com/powershell
authenticationType     True Basic                                          
configurationName      True Microsoft.Exchange                             
allowRedirection       True True                                           
requiresImport         True True                                           
isAudit               False False                                          
Verbose               False                                                
Debug                 False                                                
ErrorAction           False                                                
WarningAction         False                                                
InformationAction     False                                                
ErrorVariable         False                                                
WarningVariable       False                                                
InformationVariable   False                                                
OutVariable           False                                                
OutBuffer             False                                                
PipelineVariable      False                                                

[6/4/2024 10:58:45 AM] - ********************************************************************************
[6/4/2024 10:58:45 AM] - ********************************************************************************
[6/4/2024 10:58:45 AM] - BEGIN NEW-POWERSHELLSESSION
[6/4/2024 10:58:45 AM] - ********************************************************************************
[6/4/2024 10:58:45 AM] - Creating the powershell to server that requires import.
[6/4/2024 10:58:45 AM] - The powershell session was created successfully.
[6/4/2024 10:58:45 AM] - END NEW-POWERSHELLSESSION
[6/4/2024 10:58:45 AM] - ********************************************************************************
[6/4/2024 10:58:45 AM] - Attempting to import powershell session.
[6/4/2024 10:58:45 AM] - Unable to import powershell session.
Import-PowershellSession : Cannot bind argument to parameter 'PowershellSession' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.9.8.36\start-collectOnPremSendAs.ps1:157 char:57
+ ...  import-powershellsession -powershellsession $sessionToImport -isAudi ...
+                                                  ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Import-PowershellSession], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Import-PowershellSession

[6/4/2024 10:58:45 AM] - ********************************************************************************
[6/4/2024 10:58:45 AM] - BEGIN disable-allPowerShellSessions
[6/4/2024 10:58:45 AM] - ********************************************************************************
[6/4/2024 10:58:45 AM] - Determining if the temporary DL should be cleaned up.
[6/4/2024 10:58:45 AM] - Skip temporary DL removal.
[6/4/2024 10:58:45 AM] - Determining if the original DL should be moved back to the original OU due to failure.
[6/4/2024 10:58:45 AM] - Skip moving original DL to original OU.
[6/4/2024 10:58:45 AM] - Gathering all PS Sessions
[6/4/2024 10:58:45 AM] - Disconnecting Exchange Online Session
[6/4/2024 10:58:45 AM] - Error disconnecting powershell graph - hard abort since this is called in exit code.
[6/4/2024 10:58:45 AM] - ***IT MAY BE NECESSARY TO EXIT THIS POWERSHELL WINDOW AND REOPEN TO RESTART FROM A FAILED MIGRATION***
[6/4/2024 10:58:45 AM] - END disable-allPowerShellSessions
[6/4/2024 10:58:45 AM] - ********************************************************************************

I can provide the un-obfuscated parts, but not in a github issue (-:

I hope to have some test DL created soon.

timmcmic commented 1 month ago

Change the -exchangeAuthenticationMethod "Kerberos"

You've specified a single server name and it's defaulting to basic auth. I'll go back and look I thought I made this Kerberos already.

Tim

From: Arne-RFA @.> Sent: Tuesday, June 4, 2024 11:22 AM To: timmcmic/DLConversionV2 @.> Cc: Subscribed @.***> Subject: [timmcmic/DLConversionV2] error with "start-collectOnPremSendAs" (Issue #174)

Running from W11 Pro 23H2, AD joined.

PowerShell Version

Name Value


PSVersion 5.1.22621.2506

PSEdition Desktop

PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}

BuildVersion 10.0.22621.2506

CLRVersion 4.0.30319.42000

WSManStackVersion 3.0

PSRemotingProtocolVersion 2.3

SerializationVersion 1.1.0.1

After having much fun with modules, this seems to work to have the correct set installed and imported.

cleanup graph1

Uninstall-Module Microsoft.Graph -AllVersions

cleanup graph2

Get-InstalledModule Microsoft.Graph.* | ? Name -ne "Microsoft.Graph.Authentication" | Uninstall-Module -AllVersions

cleanup graph1

Uninstall-Module Microsoft.Graph.Authentication -AllVersions

cleanup EXO

Uninstall-Module -Name ExchangeOnlineManagement

install graph auth 2.9.1

Install-Module -Name Microsoft.Graph.Authentication -RequiredVersion 2.9.1

install DLConversionV2

Install-Module -Name DLConversionV2

import module

Import-module DLConversionV2

With some mild obsfuscation and removal of the cert based auth parts to set variables

Define on premises credentials. (This assumes credential XMLs were previously defined.)

$adCred = import-cliXML "C:\TEMPDIR\DLMigrate\credentials\adCred.XML"

$exchangeOnPremCred = import-cliXML "C:\TEMPDIR\DLMigrate\credentials\adCred.XML"

Define Active Directory information

$globalCatalogServer = "US-DCFILE01.nyc.clientdomain.com"

Define EntraID Connect information

$aadConnectServer = "us-aadc.nyc.clientdomain.com"

$Define Exchange On Premises information

$exchangeServer = "US-EXCH02.nyc.clientdomain.com"

Define ms graph connection information

$msGraphTenantID=""

$msGraphCertificateThumbprint=""

$msGraphApplicationID=""

Define Exchange Online connection information

$exchangeOnlineCertificateThumbPrint=""

$exchangeOnlineOrganizationName=""

$exchangeOnlineAppID=""

Define additional parameters

$enableHybridMailFlow = $TRUE

$logFolderPath = "C:\TEMPDIR\DLMigrate\DLMigrations"

$dnNoSyncOU = "OU=DL-Migrate-NoSync,DC=nyc,DC=clientdomain,DC=com"

$groupSMTPAddress = @.**@.>"

When I run the below

start-collectOnPremSendAs -logFolderPath $logFolderPath -exchangeServer $exchangeServer -exchangeCredential $exchangeOnPremCred

It errors out with

[6/4/2024 10:58:45 AM] - ================================================================================

[6/4/2024 10:58:45 AM] - START LOG FILE

[6/4/2024 10:58:45 AM] - ================================================================================

[6/4/2024 10:58:45 AM] - ****

ParameterName Bound ParameterValue


logFolderPath True C:\TEMPDIR\DLMigrate\DLMigrations

exchangeServer True US-EXCH02.nyc.clientdomain.com

exchangeCredential True System.Management.Automation.PSCredential

exchangeAuthenticationMethod False Basic

retryCollection False False

bringMyOwnRecipients False

Verbose False

Debug False

ErrorAction False

WarningAction False

InformationAction False

ErrorVariable False

WarningVariable False

InformationVariable False

OutVariable False

OutBuffer False

PipelineVariable False

[6/4/2024 10:58:45 AM] - ****

[6/4/2024 10:58:45 AM] - Calling New-PowerShellSession

[6/4/2024 10:58:45 AM] - ****

ParameterName Bound ParameterValue


Credentials True System.Management.Automation.PSCredential

Server False

PowershellSessionName True ExchangePowershell

connectionURI True https://US-EXCH02.nyc.clientdomain.com/powershellhttps://us-exch02.nyc.clientdomain.com/powershell

authenticationType True Basic

configurationName True Microsoft.Exchange

allowRedirection True True

requiresImport True True

isAudit False False

Verbose False

Debug False

ErrorAction False

WarningAction False

InformationAction False

ErrorVariable False

WarningVariable False

InformationVariable False

OutVariable False

OutBuffer False

PipelineVariable False

[6/4/2024 10:58:45 AM] - ****

[6/4/2024 10:58:45 AM] - ****

[6/4/2024 10:58:45 AM] - BEGIN NEW-POWERSHELLSESSION

[6/4/2024 10:58:45 AM] - ****

[6/4/2024 10:58:45 AM] - Creating the powershell to server that requires import.

[6/4/2024 10:58:45 AM] - The powershell session was created successfully.

[6/4/2024 10:58:45 AM] - END NEW-POWERSHELLSESSION

[6/4/2024 10:58:45 AM] - ****

[6/4/2024 10:58:45 AM] - Attempting to import powershell session.

[6/4/2024 10:58:45 AM] - Unable to import powershell session.

Import-PowershellSession : Cannot bind argument to parameter 'PowershellSession' because it is null.

At C:\Program Files\WindowsPowerShell\Modules\DLConversionV2\2.9.8.36\start-collectOnPremSendAs.ps1:157 char:57

[6/4/2024 10:58:45 AM] - ****

[6/4/2024 10:58:45 AM] - BEGIN disable-allPowerShellSessions

[6/4/2024 10:58:45 AM] - ****

[6/4/2024 10:58:45 AM] - Determining if the temporary DL should be cleaned up.

[6/4/2024 10:58:45 AM] - Skip temporary DL removal.

[6/4/2024 10:58:45 AM] - Determining if the original DL should be moved back to the original OU due to failure.

[6/4/2024 10:58:45 AM] - Skip moving original DL to original OU.

[6/4/2024 10:58:45 AM] - Gathering all PS Sessions

[6/4/2024 10:58:45 AM] - Disconnecting Exchange Online Session

[6/4/2024 10:58:45 AM] - Error disconnecting powershell graph - hard abort since this is called in exit code.

[6/4/2024 10:58:45 AM] - IT MAY BE NECESSARY TO EXIT THIS POWERSHELL WINDOW AND REOPEN TO RESTART FROM A FAILED MIGRATION

[6/4/2024 10:58:45 AM] - END disable-allPowerShellSessions

[6/4/2024 10:58:45 AM] - ****

I can provide the un-obfuscated parts, but not in a github issue (-:

I hope to have some test DL created soon.

- Reply to this email directly, view it on GitHubhttps://github.com/timmcmic/DLConversionV2/issues/174, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKGTN6PM4WECYCGH7YF4VBTZFXLP3AVCNFSM6AAAAABIYX7IJ2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGMZTGOBQG4ZDQOI. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

Arne-RFA commented 1 month ago

thanks for the insanely fast response!

I added "-exchangeAuthenticationMethod kerberos" and it is now progressing!

It has been an interesting voyage through the multitude of blog posts, but I am slowly getting my head around it.

still trying to work out how to do the migration in a forest where there are DL in child domains and members across child domains, but that will be for tomorrow (-:

timmcmic commented 1 month ago

Just specify a global catalog server in the domain where the DL resides - the script handles the rest. You'll need enterprise admin rights in this instance.

From: Arne-RFA @.> Sent: Tuesday, June 4, 2024 12:32 PM To: timmcmic/DLConversionV2 @.> Cc: Tim McMichael @.>; Comment @.> Subject: Re: [timmcmic/DLConversionV2] error with "start-collectOnPremSendAs" (Issue #174)

thanks for the insanely fast response!

I added "-exchangeAuthenticationMethod kerberos" and it is now progressing!

It has been an interesting voyage through the multitude of blog posts, but I am slowly getting my head around it.

still trying to work out how to do the migration in a forest where there are DL in child domains and members across child domains, but that will be for tomorrow (-:

- Reply to this email directly, view it on GitHubhttps://github.com/timmcmic/DLConversionV2/issues/174#issuecomment-2147954904, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKGTN6PSBD3X6Y3DKPXVEDTZFXTYXAVCNFSM6AAAAABIYX7IJ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXHE2TIOJQGQ. You are receiving this because you commented.Message ID: @.**@.>>

Arne-RFA commented 1 month ago

GC worked (-: