Add-XenSubject
Adds to fields of a Subject object.
Syntax
Add-XenSubject [-Subject] <Subject> [-PassThru] [-Roles <XenRef[Role]>] [-BestEffort]
[-SessionOpaqueRef <string>] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-XenSubject [-Ref] <XenRef[Subject]> [-PassThru] [-Roles <XenRef[Role]>] [-BestEffort]
[-SessionOpaqueRef <string>] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-XenSubject [-Uuid] <guid> [-PassThru] [-Roles <XenRef[Role]>] [-BestEffort]
[-SessionOpaqueRef <string>] [-WhatIf] [-Confirm] [<CommonParameters>]
Description
Adds values to the collection-valued fields of a Subject. Each optional parameter listed below corresponds to a field that can be added to.
Parameters
-BestEffort
If set, the cmdlet continues processing further objects instead of throwing a terminating error when an operation fails for one object.
| Attribute | Value |
|---|---|
| Type | SwitchParameter |
| Required | False |
| Position | Named |
| Accepts pipeline input | False |
-Confirm
Prompts for confirmation before running the cmdlet.
| Attribute | Value |
|---|---|
| Type | SwitchParameter |
| Required | False |
| Position | Named |
| Accepts pipeline input | False |
| Aliases | cf |
-PassThru
If set, the cmdlet returns the affected object. By default the cmdlet does not generate any output.
| Attribute | Value |
|---|---|
| Type | SwitchParameter |
| Required | False |
| Position | Named |
| Accepts pipeline input | False |
-Ref
The Subject object to operate on, specified by its opaque reference.
| Attribute | Value |
|---|---|
| Type | XenRef[Subject] |
| Required | True |
| Position | 0 |
| Accepts pipeline input | True (ByPropertyName) |
| Aliases | opaque_ref |
-Roles
This call adds a new role to a subject
| Attribute | Value |
|---|---|
| Type | XenRef[Role] |
| Required | False |
| Position | Named |
| Accepts pipeline input | False |
-SessionOpaqueRef
The session object on which to run the cmdlet. This overrides the default session and lets you target a specific open XenServer connection.
| Attribute | Value |
|---|---|
| Type | string |
| Required | False |
| Position | Named |
| Accepts pipeline input | False |
-Subject
The Subject object to operate on.
| Attribute | Value |
|---|---|
| Type | Subject |
| Required | True |
| Position | 0 |
| Accepts pipeline input | True (ByValue) |
-Uuid
The UUID of the Subject to operate on.
| Attribute | Value |
|---|---|
| Type | guid |
| Required | True |
| Position | 0 |
| Accepts pipeline input | True (ByPropertyName) |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
| Attribute | Value |
|---|---|
| Type | SwitchParameter |
| Required | False |
| Position | Named |
| Accepts pipeline input | False |
| Aliases | wi |
Inputs
-
Subject -
XenRef[Subject] -
guid
Outputs
-
Subject -
void
Examples
Example 1: Add a roles
PS> $role = Get-XenRole | Select-Object -First 1
PS> Add-XenSubject -Roles $role -Uuid 1871ac51-ce6b-efc3-7fd0-28bc65aa39ff
This call adds a new role to a subject
Example 2: Add a roles piped from the getter
PS> $role = Get-XenRole | Select-Object -First 1
PS> Get-XenSubject -Uuid 1871ac51-ce6b-efc3-7fd0-28bc65aa39ff | Add-XenSubject -Roles $role
This call adds a new role to a subject The object is piped in, which is the usual way once you already have it.
Example 3: Add a roles by reference
PS> $role = Get-XenRole | Select-Object -First 1
PS> Add-XenSubject -Roles $role -Ref OpaqueRef:f433bf7b-2b0c-5f53-7018-7d195addb3ca
This call adds a new role to a subject -Ref takes the opaque reference, which is what the API itself uses and what the records hold.
Related links
-
Class: Subject
-
Using the XenServer PowerShell module