ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Tutorial
Monday, May 01, 2006 4:28 AM
( permalink)
I know that there are already a lot of them out there, but I would like to create a Power Shell tutorial. Mainly to make myself learn it. What things would you want to see in such a tutorial?
|
|
|
|
mcds99
-
Total Posts
:
519
- Scores: 4
-
Reward points
:
0
- Joined: 2/28/2006
-
Status: offline
|
RE: Tutorial
Friday, May 05, 2006 8:41 AM
( permalink)
Input & Output to text files and Excel
|
|
|
|
tjritch
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 11/4/2005
-
Status: offline
|
RE: Tutorial
Monday, May 15, 2006 7:04 AM
( permalink)
Collecting data (registry, file, version, HW & Software installed) about remote pcs, reporting, database (access or SQL) automation with send keys, using WMI....just to name of few of my common tasks and what I would like to learn to do in PS to compare to other cmd/scripting tools.
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Tutorial
Tuesday, May 16, 2006 4:28 AM
( permalink)
Here is some csv stuff: ## Test some csv functionality
## Let's suppose that we have a csv file named test.csv with this data:
# Process MaxHandles MaxCPU
# ------- ---------- ------
# explorer 500 100
# iexplore 500 100
# lsass 500 10
# To simply display the contents of the csv file we would do this:
"The contents of test.csv:"
import-csv test.csv
""
""
""
# Now let's put the csv information into a variable so we can work with it easily
$csvInfo = import-csv test.csv
"The contents of test.csv from a variable."
$csvInfo
""
""
""
# The variable is essentially an array of objects although in reality it is more than that
# We can access any single item like this (will access the first item):
"The first item in the variable"
$csvInfo[0]
''
''
''
# We can get just the first and third items if we needed to for some reason
"The first and third items"
$csvInfo[0,2]
""
""
""
# Let's say that we wanted to iterate through each item providing some formatted
# output:
ForEach ($item in $csvInfo){
'For the process ' + $item.Process +
' the max handle count is ' + $item.MaxHandles +
' and the max CPU time is ' + $item.MaxCPU
}
|
|
|
|
ginolard
-
Total Posts
:
1347
- Scores: 23
-
Reward points
:
0
- Joined: 8/11/2005
-
Status: offline
|
RE: Tutorial
Wednesday, June 21, 2006 10:10 PM
( permalink)
Binding to Active Directory.
|
|
|
|
Johnl
-
Total Posts
:
1
- Scores: 0
-
Reward points
:
0
- Joined: 7/13/2006
-
Status: offline
|
RE: Tutorial
Thursday, July 13, 2006 11:05 PM
( permalink)
Some more formatting stuff would be nice. Specifically, can I get to the formatter itself and modify the way things are formatted? An example of what I mean: I always liked the way some *nix shells can colour-code entries in a directory listing, and was kinda disappointed when Powershell didn't have this. I thought about customising it but didn't really want to hack my own version of the get-childitem command. Then I realised that all formatters are doing is taking a set of data and displaying it in a table or list.I wondered if I could display something like a dir listing in a table with some values in colour depending on a specific field. PS|C:\Documents and Settings\john_ludlow\My Documents>dir Directory: Microsoft.PowerShell.Core\FileSystem::C:\Documents and Settings\john_ludlow\My Documents Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 28/04/2006 16:53 161280 FDD_Template.doc -a--- 09/05/2006 10:49 29184 FLA Trip report.doc -a--- 02/06/2006 15:26 689272 GoogleToolbarInstaller.exe ... becomes PS|C:\Documents and Settings\john_ludlow\My Documents>dir | color {$_.extension -ieq "exe"} Red Directory: Microsoft.PowerShell.Core\FileSystem::C:\Documents and Settings\john_ludlow\My Documents Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 28/04/2006 16:53 161280 FDD_Template.doc -a--- 09/05/2006 10:49 29184 FLA Trip report.doc -a--- 02/06/2006 15:26 689272 GoogleToolbarInstaller.exe ... Then I figured, hey, maybe I can do that for more than just directory. PS|C:\Documents and Settings\john_ludlow\My Documents>ps | color {$_.PM -gt 1000000} Red Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 74 4 716 164 18 0.02 2632 alg 209 8 3496 484 49 0.50 3520 ccApp 231 6 2544 180 44 0.19 1552 ccEvtMgr 186 5 2476 236 33 0.27 1520 ccSetMgr 23 1 1484 1812 13 0.06 4512 cmd ... or maybe even PS|C:\Documents and Settings\john_ludlow\My Documents>ps | color {$_.PM -gt 1000000} Red -field PM Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 74 4 716 164 18 0.02 2632 alg 209 8 3496 484 49 0.50 3520 ccApp 231 6 2544 180 44 0.19 1552 ccEvtMgr 186 5 2476 236 33 0.27 1520 ccSetMgr 23 1 1484 1812 13 0.06 4512 cmd ... OK, enough use-case examples. I can't do any of this unless I can influence the formatting in a type-agnostic way. I just want to tell the output that "hey, display this field in red for this record". I'm not even sure if that is possible, but it'd be really cool if it was. Sorry for the long post
<message edited by Johnl on Thursday, July 13, 2006 11:40 PM>
|
|
|
|
wolfmandragon
-
Total Posts
:
13
- Scores: 0
-
Reward points
:
0
- Joined: 7/13/2007
-
Status: offline
|
RE: Tutorial
Friday, July 13, 2007 2:05 AM
( permalink)
One of the greatest and overlooked functions of powershell is the ability to monitor logs.
|
|
|
|
4scriptmoni
-
Total Posts
:
225
- Scores: 0
-
Reward points
:
0
- Joined: 5/3/2007
-
Status: offline
|
RE: Tutorial
Wednesday, October 17, 2007 2:38 AM
( permalink)
AS i have heard to monitor / gather event logs its the best. But is there a simple standard example??? anyobody? How about sending emails? Can a vbs easily call a ps and vice versa? cheers,
|
|
|
|
SAPIENScripter
-
Total Posts
:
283
- Scores: 2
-
Reward points
:
0
- Joined: 11/1/2006
- Location: SAPIEN Technologies
-
Status: offline
|
RE: Tutorial
Thursday, October 25, 2007 2:51 AM
( permalink)
If you want to look at event logs on the local machine you can easily use Get-EventLog. For Remote-machines you'll need to use Get-Wmiobject. If you go to blog.sapien.com, click the Windows PowerShell category then search for Event Logs you'll find a number of entries I've written on the topic. As far as sending mail, you can do it yourself with the .NET classes, or use the send mail cmdlets that come with PowerShell Community Extensions or PowerGadgets. The upcoming 2nd edition of Windows PowerShell: TFM has additional material on this topic. You can run VBS files directly from Powershell just as you would in the CMD shell. To run a Powershell script from a VBS file, you would need to use the CMD syntax and the Run or Exec method. Open a CMD prompt and type powershell /? to see the syntax.
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Tutorial
Tuesday, December 11, 2007 5:00 PM
( permalink)
*Bump* How goes your tutorial progress?
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
SAPIENScripter
-
Total Posts
:
283
- Scores: 2
-
Reward points
:
0
- Joined: 11/1/2006
- Location: SAPIEN Technologies
-
Status: offline
|
RE: Tutorial
Wednesday, December 12, 2007 12:40 AM
( permalink)
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
RE: Tutorial
Wednesday, December 12, 2007 2:18 AM
( permalink)
The tutorial is going nowhere...too much work and no free time at home. Maybe I will get a chance over the holidays.
|
|
|
|