If you have this error during a load or elsewhere in your jenkins pipeline:
You should start by checking the serialization part of the official tutorial.
If you can't find where the error could be, it might be trickier than you think.
Indeed, the non serializable variable could be hidden in your string.
If you use double quote with a dollar sign you're done, the text will be interpreted as a groovy variable and not later as a powershell variable or plain text.
Here is an example which will fail:
bat "powershell.exe -Command 'New-Item -type Directory test > $null' "
Once found, the fix is not hard, here are some solutions:
bat "powershell.exe -Command 'New-Item -type Directory test | Out-Null' " bat 'powershell.exe -Command "New-Item -type Directory test > $null" '