Resolved

Reserved keyword/variable?

avatar
(anonymous user)

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

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?:

Best regards

Pär

Product: PowerShell Universal
Version: 4.1.2

avatar

Recommended Answer

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>]

Adam Driscoll

PowerShell Expert and Software Architect at Devolutions

All Comments (2)