Hi Team
The following attached are my source files, all are working fine when I run them individually until like the below example…
Get-Service DNS* | Start-Service.
Among the attached files you can see Get-ScheduledTask and Start-ScheduledTask, all my requirement is to combine (by pipe line (|)) both Get-XXX and Start-XXX (I need vice versa) but I am in vain to change the required parameters accordingly. I am always failing in this spot. Could someone correct the Get and Start (if .ps1xml) coding and revert me.
Attached Files info:
Get-ScheduledTask - Get the scheduled tasks information on a given computer.
Start-ScheduledTask - Starts the given scheduled task
Format_SchTsks.ps1xml - FormatData for Get-ScheduledTask command.
[ol]{Sanitize your code. You shouldn’t post code that has your customer or client name. That means remove the name of the bank!}[/ol]
[ol]Start simply when you’re trying to get pipeline input to work. I agree with Tim, I don’t see anywhere that your process is outputting a powerShell object. You need to make sure that you have a line somewhere in your get-scheduledtask that outputs an object that Start-ScheduledTask will understand.[/ol]
At some point, you need your Get-ScheduledTask to have a line like this, when you iterate through each task that matches the filter.
I think this should go somewhere within the ‘ForEach T in TaskName’ script block. But the coding logic is so convoluted and I don’t understand the purpose behind it, so it’s hard for me to say where.
The key takeaway is that you Start-Scheduled task only understands two parameters, ComputerName and TaskName. You need to add to both ‘ValueFromPipelineByPropertyName=$true’, and then make sure that Get-ScheduledTask outputs these values somewhere.