The variable "$obj" hasn't been initialized. Its value is $null.
This seems to me to be a pretty clear explanation of the error when you tried to use $obj:
Set-CimInstance : Cannot bind argument to parameter 'InputObject' because it is null.
Set-CimInstance -CimInstance $obj
The actual error is:
ParameterArgumentValidationErrorNullNotAllowed
Add this cmdlet at the top of your script to detect common errors (like the one you asked about) before you encounter them at runtime:
Set-PSDebug -Strict