As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I played with one of the early beta versions of PowerShell V1, but haven't used it since it went "gold". What is the best way to get started using PowerShell?
Which version of PowerShell should I be using (V1.0 vs 2.0 CTP's)? What are you using PowerShell for? Are there any tools that make using PowerShell easier (that is, development environments)?
For learning PowerShell, there are a number of great resources
Technet Virtual Labs (Introduction to Windows PowerShell)
PowerShellCommunity.org - Forums, blogs, script repository
powershell on irc.freenode.net
PowerShell podcasts - PowerScripting.net and Get-Scripting.blogspot.com
For IDE style environments, you have PowerShell Analyzer (free) and PowerGUI (free), PowerShell Plus (commercial), PrimalScript (commercial), and Admin Script Editor (commerical).
I use PowerShell for everything that I can. Right now, I'm looking at Psake, a PowerShell based build script environment. I use if for managing my Active Directory, Hyper-V, Twitter, some keyboard automation (hosting PowerShell in a winforms app to grab keystrokes), and a ton of other stuff. Another cool project I have to check out is PSExpect for testing. I also use it for database access - monitoring changes made to rows in a database by applications. It is also integrated in to my network monitoring solution.
I am also looking to use PowerShell as a scripting engine for a project I am working on.
EDIT:
If you are just learning PowerShell, I would focus on V1. As you get more comfortable, take a look at the CTP, but too much can change from the CTP to what is actually released as V2 to make that your learning tool.
Version 2 is out and available from XP SP3, Server 2003, Vista, and Server 2008 and in the box for Win7 and Server 2008 R2. What you learned for V1 will still serve you well, but now I would concentrate on V2, as there is a superior feature set.
Good luck!
To answer your questions one by one.
Get v2.0 of the CTP. I have used 1.0 and 2.0 and have not found any stability issues with the later version and it has more functionality.
The best way to get started is to learn three basic commands and start playing with it.
Step 1 - Discover the available commands using Get-Command
To find all of the "get" commands, for example, you just type:
*Get-Command get**
To find all of the "set" commands, for example, you just type:
*Get-Command set**
Step 2 - Learn how to use each command using Get-Help
To get basic help about the Get-Command commandlet type:
Get-Help Get-Command
To get more information type:
Get-Help Get-Command -full
Step 3 - Discover object properties and methods using Get-Member
Powershell is an object oriented scripting language. Everything is a fully fledged .Net object with properties and methods.
For example to get the properties and methods on the object emitted by the Get-Process commandlet type:
Get-Process | Get-Member
There are a few other concepts that you need to understand like pipes and regular expressions, but those should already be familiar if you have already done some scripting.
What am I using it for?
Two things:
Processing log files from a massively distributed grid application. For this it has proven to be incredibly valuable and powerful.
Quick testing of .Net classes.
There are a number of PowerShell tools, for example,
PowerGUI
PowerShell Plus (not free)
PowerShell in Action is a well-regarded book.
And the Powershell team has a blog.
I just found this free ebook, linked from the Windows PowerShell blog:
Mastering PowerShell
Find a problem you need to solve and sit down and do it with PowerShell until it's fixed.
Don't give in and do it another way. Then find another, and another, etc. You'll take WAY longer at the start, but you'll be building knowledge to use going forward. As well as a script library to pull from for the future. One day you'll turn around and realize you now "know" PowerShell.
It's awesome. :)
Count me in with a vote for PowerShell in Action. There are a bunch of blogs out there as well, check out //\O//'s blog, The Huddled Masses, and JB's Powershell (SQL) as well, they go way back with the shell and have gobs of good scripts & snippets to look at.
Check PowerGUI, a PowerShell GUI and script editor. I don't use it yet, but I saw the sample videos and looks very good. Also, the site mantains a library with sample scripts.
Here is another excellent PowerShell reference.
The Ars Technica tutorial is a bit dated, but very good to get you up-and-running with PowerShell.
I would also second the suggestion to check out PowerGUI.
The PowerShell CTP is NOT supported in a production environment and a lot will change between now and the time it ships. I suggest following the many PowerShell blogs (don't forget the PowerScripting podcast). There's no shortage of good books on the topic. If you want to spend a little money, SAPIEN Technologies has some self-paced learning material at www.scriptingoutpost.com. I believe Don Jones has done a series of training videos for CBT Nuggets. You can probably find out more at concentratedtechnology.com.
I think getting into the habit of automating small tasks is a great way to train yourself in PowerShell. For example, writing a throwaway script rather than doing an onerous looking bit of text-processing by hand. It may actually take longer the first few times, but as you get quicker and build up a library of useful snippets that you can chain together you can save yourself a lot of time.
There are DNRtvs on PowerShell and PowerGUI. There are also .NET Rocks! episodes about these tools.
A chap called Guy Thomas does some good introductions to PowerShell.
I would start it on the fly. What I mean by on-the-fly is that just start to work on your real case and search for help on the web or this site for help if you don't know what to do. For sure, it will very beneficial if you spend some time to learn some basics first. This is what get on to PowerShell.
I have some blog posts on PowerShell, especially 3-serials on a real case I posted recently. Search for davidchuprogramming or go here. Good luck with your PowerShell journey.
PowerGUI was a big help in and of itself. The IntelliSense feature sold me on it, then I found some useful add-ons that were very good.
As far as resources:
Free eBooks:
Windows PowerShell Cookbook
Mastering PowerShell
PowerShell A more in-depth look
Introductory Video:
http://powergui.org/entry.jspa?externalID=2278&categoryID=361
With regard to the IDE question:
There is a rudimentary IDE which, on my computer at least, is already installed with PowerShell.
It's labeled "WindowsPowerShell ISE", and lets you do things like have several console sessions and several script files open simultaneously... one set of tabs for the scripts, one set for the console sessions, so you can click back and forth as needed.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I know that Powershell is generally considered the IT management language for windows, but why/when would you choose F# instead, which is strongly typed and 'intellisensed' ?
I'd choose F# when it was a better fit for the company I was working for, the team who'll be using it, and the task at hand. Otherwise I'd choose something else.
I can't be more specific than that without more details, but I can suggest a few questions you should ask:
What is the problem you're solving?
In which language is it easier to express the solution to the problem?
Are existing staff F# developers themselves (i.e. consider the learning curve involved)?
Will the people maintaining this code be administrators (who are usually quite familiar with Powershell, & not at all familiar with F#)?
A related hint: don't allow a profusion of languages to develop in your production code and infrastructure.
By all means experiment to find the best language to solve the problem you're having, but if you find in five years time that someone has written a core component of your solution in a language that is no longer understood by anyone in the company, you may have a serious problem on your hands.
My personal rule of thumb (of course there are exceptions) is that a project should have a core language and a scripting language to hold it all together, & that those languages should be chosen first to fit the problem domain, and secondly to maximise proficiency across the team. 'Pet languages' should be strongly discouraged in production code or infrastructure.
It depends on your problem and on who will maintain the scripts.
PowerShell is very strong in administration areas (working with files, active directory, csv/xml, computers, etc.), but it's programming abilities are quite limited (e.g. case of generics). Threading in PowerShell is not as easy as it could be. But nobody expects from administrators that they will use threads. Instead there are background jobs that satifisfy administrator's needs.
On the other hand, F# is real programming language, which means it is quite low level and therefore verbose (compared to PowerShell). Some tasks written in PowerShell are one-liners, whereas in F# you would write a lot of code. Besides that - how would you achieve running command on remote computers (Invoke-Command -computer myserver ...)?
As you see, it depends on your problem.
Very important is also who will maintain the scripts. You might be on holiday and your colleagues will need to edit the scripts. Both languages need some time to learn. IMHO it is easier to learn PowerShell; thinking in functional style needs to bend your head.
It is probably a bad idea, at this point in time, to choose to write scripts in F# if they might be needed by anyone other than yourself ...
The cadre of F# speaking people is very small, so you're creating scripts which very few people can read or edit.
The fsi executable doesn't come with the .Net Framework, nor is it part of the F# runtime redistribution package (as far as I can tell). This means the scripts can only be executed where Visual Studio with F# tools have been installed.
The obvious exception, of course, is if you're a developer working on a project where F# is a primary language, since that will mean that everyone that matters will be able to run and edit your scripts.
However, I have to say that I think even in this ideal/exceptional case, it would probably be more work to use F# if your scripting task involves tasks for which there are pre-existing cmdlets in PowerShell (ie: filesystem tasks, registry, database maintenance, active directory, exchange, the list goes on and on). Of course, you might still choose to do it if you're using these scripts as an opportunity to learn the language, but bear in mind points 1 & 2 ;-)
Is Powershell a mature enough tech for enterprise to be using?
Are its many benefits worth the time and effort to convert existing VBS scripts, or would you only use it for new scripting projects?
We are currently using a mixture of vbs and batch files, with a login script as opposed to alot of GPO.
We don't have a huge number of .NET programmers, whereas just about everyone at least knows a bit of VB.
“Mature enough” is slightly subjective and depends on what you mean exactly.
1) Is it powerful enough to get the job done? -- Yes. But it is not the best tool for all the jobs; think, choose.
2) Is it bugs/issues free? -- No. To be prepared and informed you may want to take a look at some most voted bugs/issues in here:
https://connect.microsoft.com/PowerShell/Feedback
3) Is it easy to learn? -- It depends; basically I think it is not easy for not professional programmers. But it is definitely possible, step by step, having fun:
http://blogs.msdn.com/b/powershell/archive/2010/03/09/falling-is-learning-just-focus-on-having-fun.aspx
It’s a good idea to start using PowerShell for new tools. As for the old tools (e.g. VB), I would not convert them into PowerShell unless there are good reasons. In most cases they can be perfectly called from new PowerShell tools.
Yes. PowerShell brings into one environment the power of .NET, COM, WMI, and more. I use it every day to administer a family of 30-or-more servers, and it has proved to be both stable and productive.
I think PowerShell is a powerful thing. Microsoft is going into the "administer everything from powershell" direction (MS Exchange management shell, SharePoint 2010 management shell). This makes me think that this scripting technology will not die soon. Another thing - since the administration scripts are written in PowerShell, you can learn a lot from them, and hence gain more automation of your administrative tasks.
Convert only when needed
Prefer PowerShell for new work
It is enterprise ready and there are gotchas as with anything
Doing work in PowerShell now improves your skill
Doing work in PowerShell now positions for vNext products enabled with PowerShell. Big win.
This question already has answers here:
Closed 14 years ago.
I'm looking to learn Windows PowerShell. Can someone give me some really good references on where to start?
Search the web for some base tutorials on how to start. Once you are comfortable branch into the sites showing examples. Keep in mind that PowerShell is very similar to C# and uses the .net Framework. Starting with these technologies will help further your learning in PowerShell.
PowerShell Pro
http://www.powershellpro.com/powershell-tutorial-introduction/
Basic Commands and Examples
http://weblogs.asp.net/steveschofield/archive/2007/01/25/basic-powershell-examples-couple-useful-commands.aspx
The PowerShell Guy
http://thepowershellguy.com/blogs/posh/archive/2007/03/31/powershell-examples-used-on-ars-technica.aspx
I find that the podcast http://powerscripting.wordpress.com/ is pretty good. It won't teach you every bit of syntax you need to know but it's good as an introduction, if you use it start listening to the episodes from the beginning.
I package our server releases into zip files using a batch file (Windows), running the command-line version of WinZip. Previously we did this sort of thing "by hand" but I developed the process of automating it with a batch file.
The batch file has become quite complicated because our product is complicated (i.e., Which sections are we releasing this time? Are we releasing the config files as well?) and I'm starting to run into some frustrating limitations with batch files.
Would PowerShell be a good thing to investigate as an "upgrade" to the batch file? Or is that complete overkill given that most of what it would be doing is firing off DOS commands?
Bonus: can PowerShell consume .NET assemblies? As in, could I start doing the zipping with SharpZip?
If you have a working solution, then you don't need to go to powershell. Having said that, if you plan to make changes or improve the process then I would highly recommend powershell as the way to go. Powershell can access .Net assemblies...mostly. Some assemblies are structured in a way that makes it more difficult than others.
You can check here for some resources if you decide to look at powershell.
Initially I was really excited about PowerShell. Finally a powerful native shell on Windows. However, I quickly realized that compared to your favorite unix shell PowerShell is just way too verbose. Even doing simple stuff takes way too much typing compared to what you can do with bash and GNU tools for Win32.
I like the idea, that the shell knows about different types, but if I need to do that much additional work, I prefer just getting the necessary data with the various unix stream editors.
EDIT: I just had another look at PowerShell, and I have to admit, that it does have some really useful features that are not available for the traditional unix style tools.
For one the PowerShell owns all the commands which means that it can provide a much more coherent set of features. Parameters are treated uniformly, you can search for commands, parameters and so forth using wild cards which is really useful.
The second great feature is that PowerShell lets you enumerate sources which are normally not available to stream editors such as the Windows registry, the certificate store and so forth. Of course you can have tools that does this for you and present it as text, but the PowerShell approach is just really elegant IMO.
Take a look at PowerShell Community Extensions (PSCX), its FREE and it has Zip cmdlets:
Write-Zip
Write-BZip2
Write-GZip
http://www.codeplex.com/PowerShellCX
You should watch this presentation/discussion with Jeffrey Snover, PowerShell creator and architect. If you're not amazed by the technical details (lots of "wow" moments to be had), you'll be amazed by Jeffrey's enthusiasm :). Once you get the basics, it's easy to be very productive with PowerShell.
The answer is YES - PowerShell can use .NET assemblies. There is a bit of funny business involved in v1 if you need to wire up delegates and v2 makes that much more clean.
Just call LoadFile / LoadAssembly to get the appropriate libraries in memory and away you go
[Reflection.Assembly]::LoadFile('/path/to/sharpzip.dll')
$zip = new-object ICSharpCode.SharpZipLib.Zip.FastZip
$zip.CreateZip('C:\Sample.zip', 'C:\BuildFiles\', 'true', '^au')
# note - I didn't actually test this code
# I don't have SharpZip downloaded - just read their reference.
Also note that the PowerShell Community Extensions support various compression methods like write-zip.
I've tried to replace one of the lengthy build batch files I use with power shell. I found it a pain: at least at that time, documentation focused on the funny verbiage and what cool, perly things you can do with it, but lacked in the "getting simple things done" category. I got it working, but the error handling was to shaky.
YMMV, try powershell, you might enjoy it. But try it before updating your build batches.
My solution: use a C# console application. I've got serious logging, exception handling, can use my utility functions, and if something doesn't work I have a real debugger. It's the first solution I like to modify.
I'm not sure about powershell, but might I recommend using something like IronPython (if you want to have access to the .NET libraries) or plain python? You get a full-blown programming language with very few limitations.
On the one hand, if it works, just leave it. But it sounds like this is something you'll be adding to over time, and of course your eventual successor/coworker who needs to edit the batch file will also need to understand it. If you're from a programming background then you may well find the power of Powershell makes your script a lot shorter and easier to read/maintain (for example, even just having full if statements and for/while loops). On the other hand if you're not overly familiar with programming, a lot of people find Powershell a bit daunting at first glance.
Regarding the .NET part, Powershell is built on top of .NET so yes, you can access .NET assemblies (but you should always see if there's a cmdlet available first).
I would recommend a book called "The Powershell Cookbook" by Lee Holmes, published by O'Reilly. It provides "recipes" which you can use for common tasks; this will probably speed up your time to implement the script, and it'll teach you Powershell along the way.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What is the average time that it would take a complete novice, whose background is mostly Windows XP, to go through the FreeBSD handbook and get sufficient mastery to setup a server from the ground up?
It's impossible to say. Not only is it highly dependent upon what sort of person you are, but it also depends on what exactly you are doing and how you define "sufficient mastery". Being able to get Apache operational is a simple matter of following step-by-step tutorials, you could do that in a matter of hours. Being able to run a multi-user server competently takes a hell of a lot longer, and the handbook isn't nearly enough.
It would depend on how much knowledge you have of unix, and from the sounds of things, you probably do not have a whole lot.
Assuming you have little knowledge of unix at all, I would say that it will probably take a few days to get a grasp of what is going on, and possibly a week to have something working.
The FreeBSD handbook is pretty detailed though, and does provide you with a good grounding of everything you need to do to get things to work.
I know that this sounds like an awful lot of time, but in my experience, they really are quite different OS paradigms.
You could start with PC BSD (an easy to use distro) to get a feeling of BSD and then move to more advanced stuff like setting up servers.
As others have noted, configuring a service to do a couple of things isn't very hard, you just have to follow some steps (which any monkey could do), but if you want more, you'll need extra time. A competent sysadmin does not know only the how, but also the why. Grandma can click all day in Windows and even if Windows Server has a GUI for server administration, it doesn't mean she can configure IIS or the DHCP service. By the way, it would be a good thing if you could learn an (Unix) editor, preferably vi, since it's the standard on BSDs; emacs, joe, pico are nice too, but they aren't so popular.
As for the time, it took about two days for me to configure a server. But I had previous Linux experience and the server didn't do anything fancy.
Look if you've never touched a Unix platform, you should learn a lot of things, basically a different philosophy. The FreeBSD Handbook and the community is simply wonderful, but a reference book like the FBSD handbook contains a lot of information that you must develop yourself.
Also, the BSD platform is not easiest of the Unix family to begin from zero.
Good sources to learn:
Absolute BSD book.
The Complete BSD book (this is for Release 5, it's good for learning also).
Man pages. The BSDs man pages are a LOT better than the Linux ones.
FreeBSD Handbook.
FreeBSD forums: forums.freebsd.org and daemonforums.
Any Unix/Linux resource you can get your hands on. Many things are compatible (or near-compatible). e.g, if your friend tells you "I've found an old SGI IRIX / HPUX or (insert unix here) manual that I will throw in the thrashcan" stop it and see what you can learn from it.
Keep in mind that you've a long road ahead. But you'll enjoy it.
Depends on your reading speed :-)
Depends on your needs (I mean: what kind of server).
Once upon a time I did this - installing a FreeBSD on x86- (although I had some Linux knowledge already at that time), and it took me 3 hours, mainly that much time, because I was working on another machine in parallel.
Depends on your background: Did you ever use power shell or other command line "applications" (like batches ;-). For me one of the greatest challenges to switch from a completely GUI'd operating system to an operating system that works best with a shell (something a little bit like the DOS prompt). But the moment you get the hang of it you'll be fine again.
Another aspect is the availability of a second computer beside the one you are setting up. If you can do web searches for additional information while in the midst of doing an install, it can save a lot of time.
As for the original topic, I've used Linux and Unix extensively, but have yet to get FreeBSD working after several tries over many years. I'd always get frustrated before I could get it fully installed and configured for a nice graphical desktop. (So personality obviously matters.) But it has been about two years since I've tried, and it may be simple now...
Please do not consider this a flame against FreeBSD... just a true story that for some reason I couldn't seem to make it work. If it were not a good OS, I wouldn't have attempted so many times.
If you're coming from a primarily Windows background, I think FreeBSD would be a great way to dive into UNIX, but you may also want to check out Ubuntu Linux-- specifically, Ubuntu Server.
Got a spare Pentium 4-based system laying around at home? Burn yourself a CD and go to it.
As a fan of FreeBSD myself, I have to second the recommendation for the "Absolute FreeBSD" book above-- another book worth a look is "Building a Server with FreeBSD 7."
My original rationale for choosing FreeBSD was getting better control over what gets installed-- I was really tired of installing RedHat and/or SuSE and having a few gigabytes of stuff I wasn't going to use installed as part of the base install that wasn't easily removed after the fact. I've grown rather enamored with the BSD way of doing things, but it isn't necessarily for everyone.
Something to consider-- if you have the hardware, run VMWare or VirtualBox, and set up a few virtual machines to get used to various distributions before making the commitment to install a particular one on bare hardware.