Link to home
Start Free TrialLog in
Avatar of davesnb
davesnbFlag for Canada

asked on

invoke-sqlcmd help

Hello EE,

If I wish to invoke the sql from another server  using invoke-sqlcmd, does it have to be a sql input file , or can I use the invoke-sqlcmd remotely ?

Invoke-Sqlcmd -ServerInstance "SERVER-SQL03" - ((Get-Item SQLSERVER:\SQL\SERVER-SQL03\DEFAULT).ReadErrorLog()) 

Open in new window

Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

What do you mean?
If you can run a query without providing a script with the query? Then yes, you can, as the below example shows:
Invoke-Sqlcmd -Query "SELECT ColumnName FROM TableName;" -ServerInstance "ServerName\MSSQLInstanceName" 

Open in new window

Avatar of davesnb

ASKER

If I wish to run a powershell cmdlet such as get-item , can the invoke-sqlcmd be used as per example provided ?
I'm not a PS specialist. I can perform only the basic stuffs.
Let's wait for somebody with better skills in PS.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davesnb

ASKER

OK thank you