×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

My New Years Resolution - Learn PowerShell

My New Years Resolution - Learn PowerShell

My New Years Resolution - Learn PowerShell

(OP)
I've never been one to make a new years resolution, but I think I'll try to learn powershell this year.  Last year I took a crack at learning VBScript/WMI/ADSI and hopefully I'll have just as much luck learning PowerShell this year.  I found this site (http://www.computerperformance.co.uk/powershell/) that I like for the simple fact that the majority of the examples stay away from aliases.  There is nothing wrong with aliases since it requires less typing, but for those of us learning it can make it more difficult to understand.

example - you see something like: ps | gm | ft -auto
If you're new to a language are you going to have any idea of what's going on with that line?

written out it's: get-process | get-member | format-table -auto
which isn't too much better if you're unfamiliar with the language, but it gives you a better idea of what's going on.

Just my two cents.

Anyone else come across or know of any other good sites?

dm4ever
--------------------------------------------------------------------------------
My approach to things: K.I.S.S - Keep It Simple Stupid

RE: My New Years Resolution - Learn PowerShell

Just the Microsoft scripting site has worked wonders for me.  Particularly helpful was the converting vbscript to powershell section.  

I think the first "must have" commands are "get-command" and "get-help".  Once you learn the syntax and how to use the help, it's pretty easy.  I've been able to convert some of my vbscripts and batch scripts over to PowerShell within a very short time without much trouble.

For instance, to get drive space on a remote computer, format everything nicely and perform some math function to make the sizes more readable, I did:

CODE

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" -ComputerName SRVNAME | Select-Object -Property Name,FreeSpace | ForEach-Object -Process {$_.FreeSpace = [math]::round(($_.FreeSpace)/1024/1024); $_} | Format-Table -Property Name,FreeSpace -autosize | Out-File -FilePath C:\FREESPACE.txt -append

It's surprisingly easy figure out the parameters and use other cmdlets to modify the output, e.g. "Format-Table".  And adding variables and running loops is not hard to figure out either.

Very cool stuff.  I actually requested this forum be created to the moderators as well.  I think there will be a lot of interest and usefulness for this.

RE: My New Years Resolution - Learn PowerShell

(OP)
For the free space you can do your math by dividing by 1MB or 1GB instead of 1024/1024.

($_.FreeSpace)/1MB

dm4ever
--------------------------------------------------------------------------------
My approach to things: K.I.S.S - Keep It Simple Stupid

RE: My New Years Resolution - Learn PowerShell

Huh, didn't know that.  Look, you get the first star ever in the PowerShell forum.  Congratulations.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close