Advertisement
1RedOne

How make this shorter?

Mar 23rd, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Detect which params and build URL appropriately
  2.         if ($PSCmdlet.MyInvocation.BoundParameters.Location)      {
  3.             if ($queryParams){
  4.                 #Variable present, need to update
  5.                 $queryParams += ',location'
  6.             }
  7.             else{#Variable not present, need to create
  8.                 $queryParams = '?patchFields=location'
  9.                 }
  10.            
  11.             }
  12.         if ($PSCmdlet.MyInvocation.BoundParameters.LocationStatus){
  13.             if ($queryParams){
  14.                 #Variable present, need to update
  15.                 $queryParams += ',f0x.location_status'
  16.             }
  17.             else{#Variable not present, need to create
  18.                 $queryParams = '?patchFields=f0x.location_status'
  19.                 }
  20.            
  21.             }
  22.         if ($PSCmdlet.MyInvocation.BoundParameters.Phone)         {
  23.             if ($queryParams){
  24.                 #Variable present, need to update
  25.                 $queryParams += ',f0x.phone'
  26.             }
  27.             else{#Variable not present, need to create
  28.                 $queryParams = '?patchFields=f0x.phone'
  29.                 }
  30.            
  31.             }
  32.         if ($PSCmdlet.MyInvocation.BoundParameters.Operator)      {
  33.             if ($queryParams){
  34.                 #Variable present, need to update
  35.                 $queryParams += ',f0x.operator'
  36.             }
  37.             else{#Variable not present, need to create
  38.                 $queryParams = '?patchFields=f0x.operator'
  39.                 }
  40.            
  41.             }
  42.         if ($PSCmdlet.MyInvocation.BoundParameters.TimeZone)      {
  43.             if ($queryParams){
  44.                 #Variable present, need to update
  45.                 $queryParams += ',f0x.timezone'
  46.             }
  47.             else{#Variable not present, need to create
  48.                 $queryParams = '?patchFields=f0x.timezone'
  49.                 }
  50.            
  51.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement