I'm working on a PowerShell script which is calling C# method to enable/ disable a specific task.
Everything is working fine But I only want to get the Json result. Instead I'm getting the below result, like TaskName, TaskPath and other unwanted white space. I'm using return $properties | ConvertTo-Json
return $properties | ConvertTo-Json
in my PowerShell script to convert it but looks like when we do Enable-ScheduledTask PowerShell automatically added TaskPath and TaskName.
Can anyone suggestion how I can avoid TaskName/TaskPath and get only Json data in {}.
I got my solution. I had to use out-null to suppress the output that's it. Enable-ScheduledTask -TaskPath $TaskPath -TaskName $taskName | Out-Null
I followed this: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/out-null?view=powershell-7.1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.