I have a powershell script which is working fine from PowerShell ISE, the script will move the local files to SharePoint 365 documents. When I schedule a SQL server agent job using this script getting the error below.
Please advice me what I need to do to run this script.
abc\SQLServiceAcc. A job step received an error at line 10 in a
PowerShell script. The corresponding line is 'Add-Type -Path
"C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"'. Correct the
script and reschedule the job. The error information returned by
PowerShell is: 'Could not load file or assembly 'file:///C:\Program
Files\Common Files\Microsoft Shared\Web Server
Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll' or one of its
dependencies. This assembly is built by a runtime newer than the
currently loaded runtime and cannot be loaded. '. Process Exit Code
-1. The step failed.
It depends how you are running the script and which version of SQL Server you are using.
Look at http://www.travisgan.com/2013/05/sql-server-agent-job-and-powershell.html
Related
On my Windows Server 2012 R2 server, the same server as my SQL Server service instance is running, I had upgraded to PowerShell v5.1. I proceeded to load the SqlServer module v21.1.18121. All commands loaded fine except for Read-SqlTableData and Write-SqlTableData. The darndest thing! When I load the same SqlServer module on my Win10 development box, all commands are present. I suspect something like a version problem with the available .Net framework or some such, or a collision with SQL Server's modules. Anyone with thoughts on this one?
The SqlServer module comes with the SQL Server installation and thems to be in a different version.
Module location on a SQL Server
(Get-Module -l SqlServer).path
-> C:\Program Files\WindowsPowerShell\Modules\SqlServer\SqlServer.psd1
Module location from PowerSehll gallery
(Get-Module -l SqlServer).path
-> C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.0.17279\SqlServer.psd1
You can enforce PowerSell to load a module from specific location
Install-Module -Name SqlServer
Import-Module -Name (Get-Module -l SqlServer).path -Verbose
I've just encountered the same problem. I've tried many things, but I think the problem stems from having the module SQLPS installed alongside SqlServer module. (SQLPS being an older version of sqlserver).
The steps I used: (probably a little excessive)
Close every application that may have a reference to Powershell
modules. For me this list included Visual Studio, SSMS, SQL Agent,
and of course all Powershell cmd and/or IDE.
Open a Administrator PowerShell command shell.
execute:
Uninstall-Module sqlps
Uninstall-Module sqlserver
Check the Powershell modules folder to make sure you've cleared the modules.
The place to look is:
ls "c:\program files\WindowsPowerShell\Modules"
Both of the folders "sqlps" and "sqlserver" should be missing or empty.
Now re-install sqlserver module:
Install-Module sqlserver
Check that you have the Write-SqlTableData:
Get-Command -module sqlserver
In case you suspect you have an error with versioning: I have tried and tested sqlserver module versions: 21.1.18218 & 21.0.17099
I am currently using the following command to generate a database script using SSDT:
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Script /sf:DB.dacpac /Profile:publish.xml /op:Script.sql
and the following command to publish:
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish /sf:DB.dacpac /Profile:publish.xml
Is there anyway we can merge them so it can generate a script (for audit purpose) as well as publish on the database?
Yes, it is quite recent but when you publish you can also use "/DeployScriptPath:" and give it a path and it will save the script.
Older versions of SSDT you had to do exactly what you are doing but we can now use this to do it in one step.
This will have the latest sqlpackage.exe in case you need it:
https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild/
ed
I am working with SQL Server 2014 SP3 x64 and i have installed the cumulative update 1.
I have installed Visual Studio 2013 Professional and SQL Server Data Tools - Business Intelligence for Visual Studio and it works perfectly (I can design an run SSIS packages without any issue).
I downloaded SSIS Balanced Data Distributor for the following Microsoft download Links:
Microsoft® SQL Server® 2014 SP2 Feature Pack
Microsoft® SQL Server® 2014 Feature Pack
When I run the installation packages (both x64 and x86 - from both links), I get the following Error:
Problem with this windows installer package. A program run as part of the installation did not finish as expected. Contact your support personnel or package vendor
I tried to run the .msi as administrator from cmd with no luck. (I am a member of administrators)
I also checked the following link Problem in Installing the Balanced data Distributor for SSIS 2012 which is about the same error, but i think this is a different situtation.
Any Suggestion?
Step-by-Step solution
First I executed the .msi package with logging
msiexec /i BalancedDistributor-amd64.msi /l*v "install.log"
I checked the log file untill i found the following error:
MSI (s) (5C:EC) [12:32:01:306]: Product: Microsoft Balanced Data Distributor for SQL Server 2014 (x64) -- Error 1722. There is a problem with this Windows Installer package. A program run as part of the installation did not finish as expected. Contact your support personnel or package vendor. Action RegisterBDD32, location: C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents\, command: regsvr32.exe /s "C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents\TxBDD.dll"
Which means that the package encountered an error during the Dll registration.
I extracted the .msi package using 7zip , and it contains two files BDDDll32 and BDDDll64
I renamed these files to TxBDD.dll (from the installation log this is the original name of the DLL)
I copy the files to the following directories:
32-bit >> C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents
64-bit >> C:\Program Files\Microsoft SQL Server\120\DTS\PipelineComponents
After that i started cmd as Administrator and i executed the following commands:
regsvr32.exe /s "C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents\TxBDD.dll
regsvr32.exe /s "C:\Program Files\Microsoft SQL Server\120\DTS\PipelineComponents\TxBDD.dll
After that i started Visual Studio and on SSIS toolbox i click Refresh Items, and the Balanced Data Distributor is shown.
Side Note: After checking the Event Viewer >> Windows Log >> Application, i also found the Error message listed above
References
How to extract msi files to your computer
How to see the log files of msi package installation?
Adding Custom Components to SSIS
I cant open my SQL server configuration manager getting this error message:
Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 and later servers with SQL Server Configuration Manager.
Invalid
I have searched online material and ran the mofcomp command as recommended: mofcomp “C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof”
I am now getting this error message:
MOF file has been successfully parsed
Storing data in the repository…
An error occurred while processing item 10 defined on lines 73 – 79 in file C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof:
Compiler returned error 0x80070005Error Number: 0x80070005, Facility: Win32
Description: Access is denied.
Can you please help me out, been 2 weeks sited with this problem
Run Cmd as Administrator and execute these commands:
First go to SQL Shared folder according to your sql version:
SQL 2008: C:\Program Files (x86)\Microsoft SQL Server\100\Shared\
SQL 2012: C:\Program Files (x86)\Microsoft SQL Server\110\Shared\
SQL 2014: C:\Program Files (x86)\Microsoft SQL Server\120\Shared\
SQL 2017: C:\Program Files (x86)\Microsoft SQL Server\140\Shared\ -------> My version is 2017
SQL 2019: C:\Program Files (x86)\Microsoft SQL Server\150\Shared\
Find more versions here
cd "C:\Program Files (x86)\Microsoft SQL Server\140\Shared"
Then:
mofcomp sqlmgmproviderxpsp2up.mof
Update:
The problem occurs because the Windows Management Instrumentation (WMI) provider configuration file for manage SQL Server services is missing. So the mofcomp command repairs or recreates it.
Here is more explanation:
https://learn.microsoft.com/en-us/windows/desktop/wmisdk/mofcomp
Run the #Fereydoon Barkzehy codes with Administrative Access
Sample -
cd C:\Program Files (x86)\Microsoft SQL Server\110\Shared
cd C:\Program Files (x86)\Microsoft SQL Server\140\Shared
mofcomp sqlmgmproviderxpsp2up.mof
depends on where the file "sqlmgmproviderxpsp2up.mof" is present
Youtube video
The best solution for me was to uninstall the instance and reinstall a fresh instance. This worked 100%.
What worked for me was to download the SQLEXPR_x64_Enu, run the Setup.exe and use the Repair option.
I have the same issue but it is not working at first. Second I already restarted my PC but it is not working either. What I found out is that you will run this on the folder where your SQL Server Management Studio is installed and not on the MS SQL Instance folder.
My SQL Server Management Studio which is 2016 is installed in
C:\Program Files (x86)\Microsoft SQL Server\130
But I keep on running changing folder on which I installed on my SQL Server 2012 instance:
C:\Program Files (x86)\Microsoft SQL Server\110\Shared\
After that, just run the command: mofcomp sqlmgmproviderxpsp2up.mof as everyone suggest in here.
So keep it mind the folder since that may affect your troubleshooting.
By trial and error I finally found this working solution:
I searched all sqlmgmproviderxpsp2up.mof files under C:\Program Files (x86)\Microsoft SQL Server
Running CMD as administrator I did for each result found above:
i) Change directory to go to the directory
ii) Run mofcomp sqlmgmproviderxpsp2up.mof
Reboot
Then, it works.
doing a fresh OS installation also worked for me as well. but this is a pain. Sometimes you can run the:
“C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof”
Sometimes it helps and sometimes it doesn't, all you need to do is do a fresh OS installation and then SQL installation.
How can I run a Stored Package with a .bat file? I am running it locally on a server.
To run a package from the command line, use the DTExec tool. The location of DTExec depends on the version of SQL you have installed. Assuming you have SQL Server 2008 R2, you could save the following text to a file with a .bat extension somewhere on your SQL server.
"C:\Program Files\Microsoft SQL Server\110\DTS\Binn\DTExec.exe" /f "D:\PathTo\MyPackage.dtsx"
Double click the the .bat file to execute the command above.
Here is more information on DTExec and BAT files.