I'm sorry for my mistake. I didn't see that you were using the PsTools utility instead of the shutdown command. For the tasks to work as is worked before, you will need to download the PsTools and add it to the path variable.
1-Download the PsTools from this link.
https://learn.microsoft.com/en-us/sysinternals/...
2-Extract the PsTools.zip and save it on the Local Disk C:
3-Right-click on Start then click on Run
4-Type: sysdm.cpl and click on OK
5-Click on the "Advanced" tab then click on the "Environment Variables..." button in the bottom right corner
6-Select "Path" under "System variables" at the bottom and then click on the "Edit..." button
7-A new window will be opened
8-Click on the "Browse..." button, select the PsTools folder, and click on OK on all windows opened to save the change
When finished, open the Command Prompt and check if everything is working.
1-Click on Start, search for Command Prompt and click on that
2-Type this command and press Enter:
psshutdown /?
3-If everything is working correctly, you will see a new window with the agreement terms of the PsTools, and when you click on the "Agree" button you will see the options for the "psshutdown" command
Then you can use the command "psshutdown -d" command again in the task and your computer will sleep when you lock the screen.