Creating Sistem Protection on PC Using Powershell

Hello All
I’m trying to create a task to turn on system protection for drive C and set the disk space usage to 3%
this is what I got for now:

1.folder create "C:\vss"
2.createfile until end
3.Enable-ComputerRestore -Drive "C:"
4.net start vss
5.vssadmin resize shadowstorage /for=C: /on=C: /maxsize=3%
6.end
7.delete "C:\vss\vss.ps1"
8.move __createfile "C:\vss\vss.ps1"
9.waithidden powershell.exe -executionpolicy bypass -file "C:\vss\vss.ps1"
10.folder delete “C:\vss”

this task finishes as complete
At the end, line 3 works perfectly , line 5 doesn’t work at all max storage size doesn’t get changed
Any Ideas of how to create this task differently?
thank you in advance

Possibly 32-bit redirection - start the script with

action uses wow64 redirection {not x64 of operating system}

Without that, the script will be running the 32-bit copies of Powershell and the commands it then calls.

My eye was also drawn to the % at the end of line 5. I was wondering whether that needed %-encoding, but a quick test in the debugger suggests that is working OK

Dear Trn
Thank you for your help
Worked Perfectly