import-module ./foobar.psm1
get-foobar
# hello
set-module -name foobar -RemoveFunction get-foobar,set-foobar -AddCode {
  $a='hello foobar'
  function show-foobar {
     $a
  }
}
get-foobar
# ERROR
show-foobar
#hello foobar
its possible to do this with
. $module {
 # code
}
but it more powershell way to create cmdlet
I don't think we should encourage users to be modifying modules in-session.
It's useful for debugging on occasion, but I have't seen anywhere near enough compelling use cases to make it a standard cmdlet.
Updated module a developer can load with Force parameter. In general modules can have complex session state dependencies and changing module code/variables can destroy the session. If we think about binary modules it is absolutely impossible to change anything.
This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.
Most helpful comment
I don't think we should encourage users to be modifying modules in-session.
It's useful for debugging on occasion, but I have't seen anywhere near enough compelling use cases to make it a standard cmdlet.