Reserved keyword/variable?

Hi,

I tried to do a simple API for another system to use where I send in ComputerName and Domain to retreive values from Active Directory (AD).

I think is very simple but if I use ComputerName in my script that is called by the API it does not work.
Any other name for that variable work fine it seems.

My API
image

My Script:

So If I change my script to use $ComputerName it fails with this message:

This looks really strange! It uses my parameter for the API request?:
image

Best regards
Pär

Product: PowerShell Universal
Version: 4.1.2

COpied part over to my server at home with the same result:

If I run the scriptmanually, it work fine.

Very simpel Code.

Endpoint:

New-PSUEndpoint -Url "/GetUSBX/:ComputerName" -Method @('GET') -Endpoint {
param (
    [String]$ComputerName
)
Invoke-PSUScript GetUSBX.ps1 -ComputerName $ComputerName -Wait
} -Authentication

Script:

param(
    [String]$ComputerName
)

$ComputerName

Error:

Best regard
Pär

This is because Invoke-PSUScript has a -ComputerName parameter on it already. You’ll need to avoid any of the static parameters on Invoke-PSUScript because you can’t have a dynamic parameter with the same name as a static one.

SYNTAX
    Invoke-PSUScript [-Id] <Int64> [-AppToken <String>] [-ComputerName <String>] [-Credential <Variable>]
    [-Environment <String>] [-Integrated] [-Notes <String>] [-UseDefaultCredentials] [-Wait] [-WaitForDebugger]
    [-Queue <String>] [<CommonParameters>]

    Invoke-PSUScript [-Name] <String> [-AppToken <String>] [-ComputerName <String>] [-Credential <Variable>]
    [-Environment <String>] [-Integrated] [-Notes <String>] [-UseDefaultCredentials] [-Wait] [-WaitForDebugger]
    [-Queue <String>] [<CommonParameters>]

    Invoke-PSUScript [-Script] <Script> [-AppToken <String>] [-ComputerName <String>] [-Credential <Variable>]
    [-Environment <String>] [-Integrated] [-Notes <String>] [-UseDefaultCredentials] [-Wait] [-WaitForDebugger]
    [-Queue <String>] [<CommonParameters>]
1 Like