I would like to have the SQL Server PowerShell extensions available to me whenever I start PowerShell by loading the snap-ins in my profile.ps1 script. I found an article here with a script example that shows how to do this, and this works fine on my 32-bit Windows XP box.
Unfortunately, on my 64-bit Windows 7 machine, this blows up. If I try to launch this script with the 64-bit PowerShell, I get:
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.
At C:\Users\xxxx\Documents\WindowsPowerShell\profile.ps1:84 char:13
+ Add-PSSnapin <<<< SqlServerCmdletSnapin100
+ CategoryInfo : InvalidArgument: (SqlServerCmdletSnapin100:String
[Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
If I run this instead in a 32-bit PowerShell, I get:
Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds \Microsoft.SqlServer.Management.PowerShell.sqlps' because it does not exist.
At C:\Users\xxxx\Documents\WindowsPowerShell\profile.ps1:39 char:29
+ $item = Get-ItemProperty <<<< $sqlpsreg
+ CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...owerShell.sqlps:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
I'd like to be able to run this in a 64-bit PowerShell if possible. To this end, I tracked down what I thought was the Powershell extension dlls and in a 64-bit Administrator elevated PowerShell I ran:
cd "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn"
installutil Microsoft.SqlServer.Management.PSProvider.dll
installutil Microsoft.SqlServer.Management.PSSnapins.dll
No dice. Although installutil seemed to indicate success, I still get the "No snap-ins have been registered for Windows PowerShell version 2" error message when I run the script.
Anyone have any suggestions as to where I go from here?
I've used this script without issue on x64 machines. The problem with the x86 invocation is that the script looks for registry keys which on an x64 instance are only accessible from x64 PowerShell. For the x64 invocation you could try registering the snapins since that is the error message you're receiving. Run as administrator...
Change this:
cd $sqlpsPath
Add-PSSnapin SqlServerCmdletSnapin100
Add-PSSnapin SqlServerProviderSnapin100
to this:
cd $sqlpsPath
$framework=$([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory())
Set-Alias installutil "$($framework)installutil.exe"
installutil Microsoft.SqlServer.Management.PSSnapins.dll
installutil Microsoft.SqlServer.Management.PSProvider.dll
Add-PSSnapin SqlServerCmdletSnapin100
Add-PSSnapin SqlServerProviderSnapin100
An even better solution is not use add-pssnapin instead turn sqlps into a module. I have blog post here:
http://sev17.com/2010/07/10/making-a-sqlps-module
Update for SQL Server 2012 - now ships a sqlps module you can install instead of the above blog: http://www.microsoft.com/en-us/download/details.aspx?id=35580
I realise this is a bit of an older question but with a stock standard Windows and SQL Server 2012 install you can just directly use the command Invoke-Sqlcmd without loading anything beforehand as it will auto import the sqlps module. However letting it do that will often cause issues so import the module yourself with the lines below in the same place in your code as you used to use the add-pssnapin commands
$cur = Get-Location
Import-Module 'sqlps' –DisableNameChecking
Set-Location $cur
Similar to that posted on this MS web forum.
The import-module line above changes the current path to something that makes UNC path strings like "\\server\share\path\filename.ext" not work with lots of cmd-lets. So we store the current path before and change it back after the import-module command.
It's possible the snapin assemblies are compiled for x86 only due to dependencies on native 32bit SMO COM objects. If it was possible to run them in a 64bit shell, I'm pretty sure MS would have shipped both x86 and x64 management shells.
Related
The instructions to javapackager just above Example 2-1 in the Java SE Deployment Guide/Self-Contained Application Packaging state that a jar file is required in the -deploy command.
If I use a modular jar, I get this error message:
Exception: java.lang.Exception: Error: Modules are not allowed in srcfiles: [dist\tcdmod.jar].
If I use the equivalent non-modular jar, the resulting package includes the complete runtime. But I want to use the reduced runtime I made with jlink that is in the /dist folder.
Can the javapackager command deploy with a jlink-generated runtime?
How?
The section titled "Customization of the JRE" makes no mention of the javapackager command.
The following section "Packaging for Modular Applications" has a following line:
Use the Java Packager tool to package modular applications as well as non-modular applications.
Is the Java Packager tool distinct from javapackager? There are no examples using javapackager in this section.
Here is the javapacker command that I used:
javapackager -deploy -native -outdir packages -outfile ToneCircleDrone -srcdir dist -srcfiles tcdplain.jar -appclass com.adonax.tanpura.TCDLaunch -name "ToneCircleDrone" -title "ToneCircleDrone test"
The instructions in the javapackager documentation make no mention of the scenario where a jlink runtime is used. There is a Bundler argument -Bruntime but it is only used to point to an installed runtime other than the system default, AFAIK.
The javapackager provided with JDK 9 and up uses jlink to generate the jre image:
For self-contained applications, the Java Packager for JDK 9 packages
applications with a JDK 9 runtime image generated by the jlink tool. To
package a JDK 8 or JDK 7 JRE with your application, use the JDK 8 Java
Packager.
https://docs.oracle.com/javase/9/tools/javapackager.htm#JSWOR719
You can even pass arguments to jlink using -BjlinkOptions=<options>
Additionally, -Bruntime is only valid for packages deployed using -deploy -native jnlp
For compiling a modular application, instead of -srcdir, use --module-path <dir>, and then specify the main module using -m <module name>.
EDIT: While there is no documentation on -BjlinkOptions, it is present in the javapackager source
jdk.packager/jdk.packager.internal.legacy.JLinkBundlerHelper
https://github.com/teamfx/openjfx-10-dev-rt/blob/bf971fe212e9bd14b164e4c1058bc307734e11b1/modules/jdk.packager/src/main/java/jdk/packager/internal/legacy/JLinkBundlerHelper.java#L96
Example Usage: -BjlinkOptions=compress=2 will make javapackager run jlink with the --compress=2 flag, generating the JRE image with Zip Level compression.
Aditionally, running javapackager with the flag -Bverbose=true will show you exactly which arguments are being passed to jlink with a line in the output something like this:
userArguments = {strip-debug=1 compress=2}
PowerShell has just been opened sourced (v6.0.0-alpha.10), and I'm
trying to get it to connect to a MySQL instance from OS X.
Oracle seems to suggest (if I'm reading it correctly) that they have a
.Net Core connector
here.
I ran the install like this:
Install-Package MySql.ConnectorNET.Entity -Destination /MySQL
and the output looked good:
Name Version Source Summary
---- ------- ------ -------
MySql.ConnectorNET.Data 6.8.3.2 nugget ADO.Net driver for MySQL
MySql.ConnectorNET.Entity 6.8.3.2 nugget MySql Connector/NET for Entity Framework 6
When I try loading the assembly like this:
[System.Reflection.Assembly]::Load(/MySQL/MySql.ConnectorNET.Data.6.8.3.2/lib/net45/MySql.Data.dll)
I get the following error (note that I pass the path in with a
variable $dll):
Exception calling "Load" with "1" argument(s): "Could not load
file or assembly
'/MySQL/MySql.ConnectorNET.Entity.6.8.3.2/lib/net40/MySql.Data.dll,
Culture=neutral, PublicKeyToken=null'. The given assembly name or
codebase was invalid. (Exception from HRESULT: 0x80131047)" At
/development/scripts/test.ps1:28 char:1
+ [System.Reflection.Assembly]::Load("$dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException
Any ideas on a workaround / fix? I realize that PowerShell is still in
alpha.
EDIT
I was able to install the MySQL provider using these two commands:
Register-PackageSource -Name nuget.org -ProviderName NuGet -Location https://www.nuget.org/api/v2/
Install-Package MySql.Data.EntityFrameworkCore -Destination /Volumes/Main/libraries/MySQL/ -AllowPrereleaseVersions
I tried registering all the assemblies I could think of:
Microsoft.EntityFrameworkCore.1.0.1/lib/netstandard1.3/Microsoft.EntityFrameworkCore.dll
Microsoft.Extensions.Configuration.1.0.0/lib/netstandard1.1/Microsoft.Extensions.Configuration.dll
Microsoft.Extensions.Configuration.Json.1.0.0/lib/netstandard1.3/Microsoft.Extensions.Configuration.Json.dll
MySql.Data.EntityFrameworkCore.7.0.5-IR21/lib/netstandard1.6/MySql.Data.EntityFrameworkCore.dll
MySql.Data.7.0.5-IR21/lib/netstandard1.6/MySql.Data.dll
But, when trying to create a new MySql object, it still bombs out with
this:
New-Object : Cannot find type [MySql.Data.MySqlClient]:
verify that the assembly containing this type is loaded.
That is not a .NET Core library - the word "Core" here indicates functionality shared between the EF6 and Web packages, and pre-dates the introduction of .NET Core.
Entity Framework Core has MySql libraries under development at the time of writing.
SOLUTION
So, it turns out I was on the (mostly) right track. All of the DLLs need to be loaded. Make life easier by copying them into their own directory, and then load them by iterating over each one:
copy the DLLs to a new location
Get-ChildItem "/Volumes/Main/libraries/mysql/*/lib/netstandard1.*/*.dll" | Copy-Item -Destination "/Volumes/Main/libraries/NEW_mysql" -Force
load all required DLLs
Get-ChildItem "/Volumes/Main/libraries/NEW_mysql" | ForEach-Object {
$path = "/Volumes/Main/libraries/NEW_mysql/" + $_.Name
Add-Type -Path $path -PassThru | Out-Null
}
I'm using VS2013(update 4) + CUDA 6.5 + win7-32bit
My CUDA program compiles fine without the v120xp option, I need it support winXP. But there're lots of compile error with v120xp specified.
To reproduce the problem:
Create a new project with VS2013's CUDA wizard
Change the Platform Toolset to Visual Studio 2013 - Windows XP (v120_xp)
Compile
The compile error looks like:
1>G:\vs2013\VC\include\yvals.h(666): error : expected a ";"
1>G:\vs2013\VC\include\yvals.h(667): error : expected a ";"
1>G:\vs2013\VC\include\exception(460): error : "explicit" is not allowed
1> kernel.cu
I also compiled the program with CMake, everything is ok(with the v120_xp). Though I write code with CMake, my company uses VS2013, so I need to generate a VS2013 project for my colleagues.
How to make it compile? Thanks.
Finally, a workaround for this:
Don't change the Platform Toolset, leave it as v120, and add /SUBSYSTEM:WINDOWS,5.01 or /SUBSYSTEM:CONSOLE,5.01 manually in Command Line setting
I followed this tutorial to compile mysql driver with VS2010 :
Qt - How to get|compile Mysql driver.
The compilation fails with the error : LNK1123: failure during conversion to COFF: file invalid or corrupt
I tried with with multiple versions of mysql and qt, i always get the same error.
Note: I am using Qt-4.8.4 and mysql-5.5.32-win32.
I would rebuild Qt from source, because you also need the SQL driver (not only the plugin).
The driver source is located under /src/sql/drivers/mysql
The plugin source is located under /src/plugins/sqldrivers
/src/sql/drivers/mysqldrivers.pri contains this:
contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase
contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri)
So I think that you need to run configure with the options: -qt-sql-mysql and -plugin-sql-mysql before compiling Qt.
Recompile Qt
Open a Qt 4.8.4 Command Prompt
cd \qtdir
nmake distclean
configure -debug-and-release -platform win32-msvc2010 -mp -nomake examples -nomake demos -qt-sql-mysql -plugin-sql-mysql
nmake
You might need to point configure to the correct include/library directory for MySQL, by adding this options: -I "c:\path\to\mysql\include" and -L "c:\path\to\mysql\lib"
I run Server 2008 R2 as a workstation (mainly to get Hyper-V IIS 7.5). I’ve been playing around with this system for a while and it’s hardly pure! ;-)
Today, I loaded the latest set of patches, and took the reboot opportunity to add the rtm version of PowerShell v3. I duly removed the PowerShell V3 beta, applied the monthly patches, rebooted, then added the new version of PowerShell and rebooted again.
However, I now have an issue: Anytime I try to run a workflow, I get:
PSH [C:\foo]: Provision-AD # Run the workflow
The workflow ' Provision-AD ' could not be started: Could not load file or assembly 'System.EnterpriseServices.Wrapper.dll' or one of its
dependencies. An attempt was made to load a program with an incorrect format.
At line:321 char:21
+ throw (New-Object System.Management.Automation.ErrorRecord $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (System.Manageme...etersDictionary:PSBoundParametersDictionary) [], RuntimeException
+ FullyQualifiedErrorId : StartWorkflow.InvalidArgument
The solution was easy. I did a re-install of the .NET Framework 4.0 and all is now well!