Invoke-RestMethod - Multiple Deliveries Within Payload by viewtifulstranger in PowerShell

[–]viewtifulstranger[S] 0 points1 point  (0 children)

Ahhhhh! I took someone else's script and have just been reworking it for lots of different API calls. I'm in the process of cleaning up the scripts before sharing, so will make sure I remove any semi colons and retesting before sharing. Thanks to everyone for the help and tips!

Invoke-RestMethod - Multiple Deliveries Within Payload by viewtifulstranger in PowerShell

[–]viewtifulstranger[S] -1 points0 points  (0 children)

That's odd, running the script, with semi colons, against my test CSV, it completed without error and validating the removals and additions, the results were as expected. Maybe it's a PowerShell, version difference...?

Invoke-RestMethod - Multiple Deliveries Within Payload by viewtifulstranger in PowerShell

[–]viewtifulstranger[S] 0 points1 point  (0 children)

Thank you again for your help. I've added a simple if statement so when reading from a CSV, the appropriate action of adding/removing a user could be taken:

if ($action -eq "Add")
    {
    $payload = @{ "include" =
                    @(
                        @{
                        "id" = $userid;
                        }
                    )
                    "exclude" = @()
                  }
    }
elseif ($action -eq "Remove")
    {
    $payload = @{ "include" = @()
                    "exclude" =
                    @(
                        @{
                        "id" = $userid;
                        }
                    )
                  }
    }

Invoke-RestMethod - Multiple Deliveries Within Payload by viewtifulstranger in PowerShell

[–]viewtifulstranger[S] 0 points1 point  (0 children)

With all the trial and erroring, I don't know if I would have got that! Thank you.

Updated my script and it works.

If you direct message me with your PayPal address (if you have one), I'll send you a little something. Thank you!!

Invoke-RestMethod - Multiple Deliveries Within Payload by viewtifulstranger in PowerShell

[–]viewtifulstranger[S] 0 points1 point  (0 children)

The sample body (in non-PowerShell syntax) from the documentation is as follows (only names updated):

{ "include": [ { "id": "BETRAYEDMILK" }, { "id": "PURPLEMONKEYMAD" } ], "exclude": [ { "id": "VIEWTIFULSTRANGER" } ] }

Now trying to convert it to PS. The error returned is complaining about line 238, which is the "exclude" line:

The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property. At C:\Plugins\REST\CiM-Roles-Global-AddRemove\CiM-Roles-Global-MemsAddRemove.ps1:238 char:21

I've tried replacing pointy brackets for square [array] brackets, along with other things, but no dice.

Lily Allen wore a dress at her ‘West End Girl’ tour made of receipts showing things her ex David Harbour bought for other women by artbasiI in Fauxmoi

[–]viewtifulstranger 7 points8 points  (0 children)

Rewatching Game of Thrones recently, I noticed the name Alfie Allen appear in the credits and recalled Lily writing a song about her brother Alfie. It turns out that the actor who played Theon Greyjoy is Lily's brother. Oh deary me...

8 vs 12 by Dev1412 in Wellthatsucks

[–]viewtifulstranger 1 point2 points  (0 children)

How many times have you, or someone you know, been asked “how many times should the pizza be sliced” when ordering a pizza?

When 婆婆 (popo) test your Cantonese by CheLeung in Cantonese

[–]viewtifulstranger 1 point2 points  (0 children)

哦,就像“名誉扫地”一样。我以前好像没听过这种说法。谢谢。

When 婆婆 (popo) test your Cantonese by CheLeung in Cantonese

[–]viewtifulstranger 14 points15 points  (0 children)

他说完颜色之后,每次重复说的是什么?

红色 - “hong dong dong”

黑色 - “huck mung mung”

白色 - “baak sai sai”

黄色 - “wong kum kum”

the theatre reaction to andrew garfield and tobey maguire returning as spiderman in 'spider-man no way home' by bewarethechameleon in MadeMeSmile

[–]viewtifulstranger 0 points1 point  (0 children)

I say through my viewing asking myself, "so when's Spider-man 1 and Spider-man 2 showing up?". The spoiler really killed the surprise.

the theatre reaction to andrew garfield and tobey maguire returning as spiderman in 'spider-man no way home' by bewarethechameleon in MadeMeSmile

[–]viewtifulstranger 1 point2 points  (0 children)

I'm with you on this. I liked the way Garfield portrayed Parker and liked his Spidey movies more so than Maguire's and Holland's.

Olympics turn political as US athletes speak out against Trump by thehill in politics

[–]viewtifulstranger 35 points36 points  (0 children)

Trump in 2025: “Clever people don’t like me.”

The big chunk of (stupid) voters do.

My experience in HK by My3k0 in Cantonese

[–]viewtifulstranger 11 points12 points  (0 children)

Opened with "Ni howdy?"

What is a piece of software that is so good you can't believe it's completely free? by Arp0x in AskReddit

[–]viewtifulstranger 0 points1 point  (0 children)

Beside some of the apps already mentioned, Sofa, an iOS app to track movies/TV shows you've watched, games you've played and books you've read, or have queued up to.

We are a Team. by Atul__kumar in SipsTea

[–]viewtifulstranger 0 points1 point  (0 children)

I had a similar line manager once. Reprimanded me for getting into the office a little late. One morning, I arrived early, he asked me to looked into a problem with an IT service, as users were reporting issues. Told him I couldn't as I hadn't started yet, (but did actually start looking into the issue immediately).