-
-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PowerShell 7.4.6 along with dbatools 2.1.28 & dbatools.library 2024.4.12 - Microsoft.DataSqlClient.dll - Assembly with same name is already loaded #9566
Comments
I just tried this method from , but getting same error: WrapperScript.ps1Path to the main script$scriptPath = "C:\path\to\CopyJobs.ps1" Use pwsh -c to run the main script in a new sessionpwsh -c "& '$scriptPath'" |
I have also tried the following method: Same error message. |
I was able to get this to run several times, but still testing: Unload the conflicting assembly if it's already loaded$assembly = [System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -eq "Microsoft.Data.SqlClient" } Load the required assembly$dllPath = "C:\path\to\Microsoft.Data.SqlClient.dll" I still have to run a clean PS session via the WrapperScript.ps1, but by adding the following on the main script, it seems to work thus far. Still does not explain why the sudden change after updating Powershell and dbatools. |
Have you looked at your Does |
PowerShell 7.4.6
$PROFILE | select *
AllUsersAllHosts : C:\Program Files\PowerShell\7\profile.ps1
AllUsersCurrentHost : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : C:\Users\xxx\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\xxx\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Length : 77
cd C:\"Program Files"\PowerShell\7\profile.ps1
- Set-Location: Cannot find path 'C:\Program Files\PowerShell\7\profile.ps1' because it does not exist.
cd C:\"Program Files"\PowerShell\7\Microsoft.PowerShell_profile.ps1
- Set-Location: Cannot find path 'C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1' because it does not exist.
cd C:\Users\xxx\Documents\PowerShell\profile.ps1
- Set-Location: Cannot find path 'C:\Users\xxx\Documents\PowerShell\profile.ps1' because it does not exist.
cd C:\Users\xxx\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
- Set-Location: Cannot find path 'C:\Users\xxx\Documents\PowerShell\Microsoft.PowerShell_profile.ps1' because it does not exist.
So, when I run pwsh and then type pwsh -noprofile, I am able to run the .ps1 script without the Assembly error.
PS C:\Users\xxx> pwsh -NoProfile
PowerShell 7.4.6
PS C:\Users\xxx> cd E:\PS_SCRIPTS\AgentJobs\AG04\
PS E:\PS_SCRIPTS\AgentJobs\AG04> .\CopyAgentJob_AG04_06_FILE.ps1
ComputerName : AG06
InstanceName : FILE
SqlInstance : AG06\FILE
Name : Claim Non-Indexed ACS Ingestion Documents
Status : Dropped
Not sure what that tells us except for my profile is corrupt? How do you suggest I fix this?
Classified as General
From: Matt Cargile ***@***.***>
Sent: Tuesday, January 7, 2025 4:12 PM
To: dataplat/dbatools ***@***.***>
Cc: Crawford, Adam ***@***.***>; Author ***@***.***>
Subject: [External] Re: [dataplat/dbatools] PowerShell 7.4.6 along with dbatools 2.1.28 & dbatools.library 2024.4.12 - Microsoft.DataSqlClient.dll - Assembly with same name is already loaded (Issue #9566)
Have you looked at your $PROFILE | select * files to see if any other modules are being loaded or the like? I am fairly perplexed by your issue. Does Get-DbaAgentJob work if you launch pwsh from the Run Dialog box by hitting WIN + r keys then
Have you looked at your $PROFILE | select * files to see if any other modules are being loaded or the like? I am fairly perplexed by your issue.
Does Get-DbaAgentJob work if you launch pwsh from the Run Dialog box by hitting WIN + r keys then typing pwsh -noprofile?
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https:/github.com/dataplat/dbatools/issues/9566*issuecomment-2576228361__;Iw!!CsmrWXz9mOkSc4Hdn1fjj00!y5toh_tpSr9zpQ9tIHC_fHzr3Yd1l5u19qJhkPhBhTl0sClcUtJmAv7nN5ngLOSWlCWpxBKhSHu205TI6ZXx5ZRg$>, or unsubscribe<https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/BNYFWSNU6UOU2DZLGXZRML32JQ7LRAVCNFSM6AAAAABTW6VLNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZWGIZDQMZWGE__;!!CsmrWXz9mOkSc4Hdn1fjj00!y5toh_tpSr9zpQ9tIHC_fHzr3Yd1l5u19qJhkPhBhTl0sClcUtJmAv7nN5ngLOSWlCWpxBKhSHu205TI6cWblHsz$>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
This email transmission, including any attachments, is intended solely for the addressee named above, and may contain confidential or privileged information. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender immediately by reply email and destroy the message and its attachments.
|
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
Get-DbaAgentJob -SqlInstance $DestinationServer | Where-Object { …
The text was updated successfully, but these errors were encountered: