Share via


Set-SmaVariable

Creates or modifies a variable in SMA.

Syntax

Default (Default)

Set-SmaVariable
    -Name <String>
    -Value <Object>
    [-Description <String>]
    [-Encrypted]
    [-Force]
    -WebServiceEndpoint <String>
    [-Port <Int32>]
    [-AuthenticationType <String>]
    [-Credential <PSCredential>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Set-SmaVariable cmdlet creates or modifies a variable in System Management Automation (SMA). Specify the name of the variable and a value.

To encrypt the variable, use the Encrypted parameter. You cannot modify the encrypted state of a variable after creation. This cmdlet will fail if you use the Encrypted parameter on an existing, non-encrypted variable.

Examples

Example 1: Assign a value to a variable

PS C:\> Set-SmaVariable -Name "Variable01" -Value "String07" -WebServiceEndpoint "https://contoso.com/app01" -Encrypted

This command assigns the value String07 to the variable named Variable01 for the specified web service endpoint. Because the command specifies the Encrypted parameter, it encrypts the variable.

Parameters

-AuthenticationType

Specifies the authentication type. Valid values are:

  • Basic
  • Windows

The default value for this parameter is Windows. If you use Basic authentication, you must provide credentials by using the Credential parameter.

Parameter properties

Type:String
Default value:None
Accepted values:Basic, Windows
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Credential

Specifies a PSCredential object for the connection to the SMA web service. To obtain a credential object, use the Get-Credential cmdlet. For more information, type Get-Help Get-Credential.

Parameter properties

Type:PSCredential
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Description

Provides a description for the variable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Encrypted

Indicates that this cmdlet encrypts the variable.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Modifies the variable without prompting you for confirmation. The cmdlet prompts you for confirmation before it proceeds if you provide a SecureString as the value for the Value parameter. This cmdlet also prompts you if the value contains an object with SecureString as a field and you do not use the Encrypted parameter.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies the name of a variable.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Port

Specifies the port number of the SMA web service.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Value

Specifies a value for the variable.

Parameter properties

Type:Object
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WebServiceEndpoint

Specifies the endpoint, as a URL, of the SMA web service. You must include the protocol, for example, http:// or https://.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.