I'm coming from a unix background where I've written some scripts using bash and bourne. But I need to write some scripts using powershell and I'm having a hard time finding information.
For example, in *nix, I can do man bash
and read all about how to use bash and I can do man some_command
to read about a specific command. So far, I found some powershell equivalents like get-command
to see all available commands, but getting and using objects is really confusing me.
For instance, I'm trying to create a new scheduled task using powershell and found some sample code here on SO. Here is a snippit:
$schedule = new-object -com Schedule.Service
$schedule.connect()
$tasks = $schedule.getfolder("\").gettasks(0)
$tasks | select Name, LastRunTime
foreach ($t in $tasks) {
foreach ($a in $t.Actions) {
$a.Path
}
}
I understand what this script is doing, but without experience how would I know to do the following:
- Know to use
new-object -com Schedule.Service
- Know that this object has a
.connect
method - Know that this object has a
.getfolder
and.gettasks
object
A lot of the code seems ambiguous to me, so where would I find out the above information natively using powershell?