Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Powershell scripts do not fail, but don't work

Author  Topic 

Analyzer
Posting Yak Master

115 Posts

Posted - 2012-11-13 : 07:22:51
New to PS and trying to build an inventory framework.

Sourced various .ps1 scripts from net, modified some. Can get a few scripts to work however most of them execute without any errors - however - I don't get any results. Not in shell, .txt or piping using cmdlets Out-file, write-file.

Any ideas what is preventing the scripts from producing results? They still don't work when runas 'admin', inside SQL module and Set-ExecutionPolicy Unrestricted.

Invoke-Sqlcmd2 -ServerInstance <svr_name> -Query "PRINT 'hello world'" -Verbose,

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-11-13 : 07:43:53
quote:
Originally posted by Analyzer

New to PS and trying to build an inventory framework.

Sourced various .ps1 scripts from net, modified some. Can get a few scripts to work however most of them execute without any errors - however - I don't get any results. Not in shell, .txt or piping using cmdlets Out-file, write-file.

Any ideas what is preventing the scripts from producing results? They still don't work when runas 'admin', inside SQL module and Set-ExecutionPolicy Unrestricted.

Invoke-Sqlcmd2 -ServerInstance <svr_name> -Query "PRINT 'hello world'" -Verbose,

These may be typos that is only in your posting, but the comma at the end causes Powershell to think that the command is not complete.

Also, Invoke-Sqlcmd2 - I am not familiar with it, but I see in the code repository as an improved version that avoids timeouts. Does simple Invoke-Sqlcmd work for you?
Go to Top of Page
   

- Advertisement -