SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Powershell scripts do not fail, but don't work
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Analyzer
Posting Yak Master

United Kingdom
102 Posts

Posted - 11/13/2012 :  07:22:51  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/13/2012 :  07:43:53  Show Profile  Reply with Quote
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?

Edited by - sunitabeck on 11/13/2012 07:45:42
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000