Been having a weird issue with one of my scripts in PS Automation, keep getting this error despite not using #requires anywhere in the script and the rest of our scripts work fine.
[3:30:14 PM] [ERR] Cannot process the #requires statement because it is not in the correct format.
The #requires statement must be in one of the following formats:
“#requires -shellid ”
“#requires -version <major.minor>”
“#requires -psedition ”
“#requires -pssnapin [-version <major.minor>]”
“#requires -modules ”
“#requires -runasadministrator”
Very possibly! I went through this morning and slimmed down the script a bit, just have one module it pulls in now, still getting the same error. I can run the script manually on our machine hosting PSU and I am not getting the error which is also strange.
Its running in 5.1, the module is a home grown one we made to interact with Ivanti HEAT and its installed to C:\Progam File\WindowsPowershell\Modules.
This is driving me up such a wall I went though each of the commands in the module and searched for #requires and removed anything close, still no dice.
Yepp! I actually just commented out the few lines that called the module/imported it, still getting the same error so I must have done something exceptionally weird
I’m mostly wondering if you can use that as a debugging step to get some more information (like a stack trace) as to where the error is originating from.
Oook, I think I figured it out and pretty sure it was self inflicted by my bad scripting . Originally had a param() block at the top of the module and had them laid out like:
When I hacked the Parameter off the top it seems to work as intended. Originally this was going to be a module, but wanted to try putting it in PSU and may have shot myself in the foot during the transition.