March 21, 2012 at 10:50 pm
Comments posted to this topic are about the item A demo about the power of powershell
March 22, 2012 at 3:23 am
Lovely! Tasks get easier everyday.
I have never use PowerShell though. Can you please tell me the resources that I need to get started on PowerShell. Thanks
March 22, 2012 at 6:10 am
Best way to learn Powershell is Bruce Payette's book: PowerShell in Action. First edition is just fine, second covers remoting as well.
But Daniel, why do you use "echo $var" to output something in Powershell? It's way nicer to just tell that whatever the evaluation result is the output. So $var in itself will print out the variable.
Cheers,
Erik
-- Erik http://blog.rollback.hu
March 22, 2012 at 8:22 am
Thanks for posting a basic Powershell article. Most Powershell articles I've read assume that I already know most of how it works - but I don't because I haven't started using it. I tried your demo on my dev server and was happy to see it work. 😀
March 22, 2012 at 8:44 am
What I like about powershell is that Linux and Unix users can also play with it like they were at home. That's why I used the echo. There are many alias that can help to linux users to learn PS easily.
March 22, 2012 at 5:16 pm
Though its great all the features of powershell for all of MS's offerings. It still makes me feel like they are unfinished products or features. Where 'gui'ed features appear more tested in a variety of environments.
March 23, 2012 at 6:53 am
Yes, I believe that powershell will progress a lot in the future.
March 25, 2012 at 3:56 am
Excellent article Daniel. You showed in simple steps how useful powershell can be.
M&M
March 25, 2012 at 2:00 pm
Gosh... I'm torn. This article is really a nice simple article on how to loop in powershell and probably should have been advertised that way. On the other hand, it shows a disturbing trend.
Powershell is becoming just like Cursors, Recursive CTEs, and CLR. It's the next "cool thing" and everyone is going to demo it with and use it for things they really shouldn't. As the saying goes, just because something can be done a certain way, doesn't mean it should.
I also think it's odd that we've come full circle. It used to be that people complained about having to maintain things by script instead of by GUI and now the opposite is becoming true. People with straight hair want curly hair and people with curly hair want straight hair. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
March 25, 2012 at 7:21 pm
Yeah I'm kind of torn about this. It's an indicative demonstration I guess.
There's no denying that for scripts that need to do automated and extremely nifty things, powershell is probably the future. Creating databases is not really one of those things though. You still have to go and modify all necessary settings on each database from their server default, like a good DBA. Yes you could probably do all that in PS too, but why when there's SSMS?
March 26, 2012 at 12:50 am
Hi all,
When I run $list | ForEach-Object {Invoke-SqlCmd -Query "create database $_"}
I get:
The term 'invoke-sqlcmd' is not recognized as the name of a cmdlet, function, s
cript file, or operable program. Check the spelling of the name, or if a path w
as included, verify that the path is correct and try again.
At line:1 char:38
+ $list | ForEach-Object (invoke-sqlcmd <<<< -Query "create database $_")
+ CategoryInfo : ObjectNotFound: (invoke-sqlcmd:String) [], Comma
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
What am I doing wrong???, maybe Powershell version?? Mine is 1.0
Regards.
March 26, 2012 at 1:37 am
Jeff Moden (3/25/2012)
Powershell is becoming just like Cursors, Recursive CTEs, and CLR. It's the next "cool thing" and everyone is going to demo it with and use it for things they really shouldn't. As the saying goes, just because something can be done a certain way, doesn't mean it should.I also think it's odd that we've come full circle. It used to be that people complained about having to maintain things by script instead of by GUI and now the opposite is becoming true. People with straight hair want curly hair and people with curly hair want straight hair. 😉
On what aspects you recommend using Powershell in SQL Server? I am little confused with your comments.
Could you please throw some light, it would be great for Powershell newbies to hear from you 🙂
M&M
March 26, 2012 at 1:39 am
carl_corpus (3/26/2012)
Hi all,When I run $list | ForEach-Object {Invoke-SqlCmd -Query "create database $_"}
I get:
The term 'invoke-sqlcmd' is not recognized as the name of a cmdlet, function, s
cript file, or operable program. Check the spelling of the name, or if a path w
as included, verify that the path is correct and try again.
At line:1 char:38
+ $list | ForEach-Object (invoke-sqlcmd <<<< -Query "create database $_")
+ CategoryInfo : ObjectNotFound: (invoke-sqlcmd:String) [], Comma
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
What am I doing wrong???, maybe Powershell version?? Mine is 1.0
Regards.
Try running this inside SQLPS.
i.e after you go to powershell console, type SQLPS and then follow the steps as described by Daniel.
M&M
March 26, 2012 at 7:13 am
mohammed moinudheen (3/26/2012)
Jeff Moden (3/25/2012)
Powershell is becoming just like Cursors, Recursive CTEs, and CLR. It's the next "cool thing" and everyone is going to demo it with and use it for things they really shouldn't. As the saying goes, just because something can be done a certain way, doesn't mean it should.I also think it's odd that we've come full circle. It used to be that people complained about having to maintain things by script instead of by GUI and now the opposite is becoming true. People with straight hair want curly hair and people with curly hair want straight hair. 😉
On what aspects you recommend using Powershell in SQL Server? I am little confused with your comments.
Could you please throw some light, it would be great for Powershell newbies to hear from you 🙂
I'd use powershell for things that can't be done in SQL Server. Things like "auto-discovery" of servers and doing hard-disk "audits" on them to make sure they're not running out of space or for things that require the interogation of Active Directory, etc. Just like with CLR, there are a ton of things that SQL Server either can't do or isn't very good at doing that powershell could be used for. I agree that this article was mostly about a simple looping example and for that purpose it was great. I just hope that no one thinks that using powershell to create multiple databases in an ongoing basis is a good thing. It could be a good thing if you're building an "installation script" for a product, though. As always, "It Depends".
--Jeff Moden
Change is inevitable... Change for the better is not.
March 26, 2012 at 7:20 am
Yes, powershell for SQL Server was included in SQL Server 2008. It was the sqlps. In SQL 2012, the powershell 2.0 includes de SQL command and it is not a separated application anymore.
Viewing 15 posts - 1 through 15 (of 18 total)
You must be logged in to reply to this topic. Login to reply