code: def copy_user(target_portal, source_user, password):
      # See if the user has firstName and lastName properties
      try:
          first_name = source_user.firstName
          last_name = source_user.lastName
      except:
          # if not, split the fullName
          full_name = source_user.fullName
          first_name = full_name.split()[0]
          try:
              last_name = full_name.split()[1]
          except:
              last_name = "NoLastName"
  
      try:
          # create user
          target_user = target_portal.users.create(
              source_user.username,
              password,
              first_name,
              last_name,
              source_user.email,
              source_user.description,
              source_user.role,
          )
  
          # update user properties
          target_user.update(
              source_user.access,
              source_user.preferredView,
              source_user.description,
              source_user.tags,
              source_user.get_thumbnail_link(),
              culture=source_user.culture,
              region=source_user.region,
          )
          return target_user
  
      except Exception as Ex:
          print(str(Ex))
          print("Unable to create user " + source_user.username)
          return None
  
imports: from arcgis.gis import GIS
  from getpass import getpass
  import tempfile
label_desc: Use image node_id 1 for calling a global function with example usage: copy_user(target_portal, source_user, password) and returns: target_user, None