Set-SCScript

Changes the properties of a script stored in the VMM library.

Syntax

Set-SCScript
   [-UserRole <UserRole>]
   [-Enabled <Boolean>]
   [-VMMServer <ServerConnection>]
   [-Script] <Script>
   [-Name <String>]
   [-SharePath <String>]
   [-Description <String>]
   [-Owner <String>]
   [-FamilyName <String>]
   [-Release <String>]
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]
Set-SCScript
   [-VMMServer <ServerConnection>]
   [-Scripts] <System.Collections.Generic.List`1[Microsoft.SystemCenter.VirtualMachineManager.Script]>
   -FamilyName <String>
   -Release <String>
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]

Description

The Set-SCScript cmdlet changes one or more properties of a script stored in the Virtual Machine Manager (VMM) library.

Properties that you can change include:

  • Description
  • Enabled
  • Name
  • Owner
  • SharePath

Script objects represent script files stored in a library share on a library server. Typically, these scripts are either Windows PowerShell® scripts or answer files (such as a Sysprep.inf or an Unattend.xml file) that contain the inputs required for the Windows Setup program.

Examples

Example 1: Change the description of a script

PS C:\> $Script = Get-SCScript -VMMServer "VMMServer01.Contoso.com" | where { $_.LibraryServer.Name -eq "LibraryServer01.Contoso.com" -and $_.Name -eq "Sysprep.inf" }
PS C:\> Set-SCScript -Script $Script -Description "Windows Server 2008 R2 Sysprep Answer File"

The first command retrieves the answer file script object named Sysprep.inf from the library on VMMServer01and then stores the object in the $Script variable.

The second command changes the description of this script object to "Windows Server 2008 R2 Sysprep Answer File".

Example 2: Disable a Windows PowerShell script stored in the VMM library

PS C:\> $Script = Get-SCScript -VMMServer "VMMServer01.Contoso.com" | where { $_.LibraryServer.Name -eq "LibraryServer01.Contoso.com" -and $_.Name -eq "AddHost.ps1" }
PS C:\> Set-SCScript -Script $Script -Enabled $FALSE

The first command gets the the PowerShell script object named AddHost.ps1 and stores the object in the $Script variable.

The second command disables the script stored in $Script.

Example 3: Specify an owner for all scripts with an unknown owner

PS C:\> Get-SCScript -VMMServer "VMMServer01.Contoso.com" | where {$_.Owner -eq "Unknown"} | Set-SCScript -Owner "Contoso\PattiFuller"

This command gets all script objects from the VMM library whose owner is Unknown, and then specifies an owner for each script object.

Parameters

-Description

Specifies a description for the script.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Enabled

Enables an object when set to $True, or disables an object when set to $False. For example, if you want to upgrade software on a virtual machine template, you can disable the template object in the VMM library to temporarily prevent users from using that object.

Type:Boolean
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-FamilyName

Specifies a family name for a physical resource in the VMM library. This value is used in conjunction with Release, Namespace, and Type to establish equivalency among library resources.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-JobVariable

Specifies that job progress is tracked and stored in the variable named by this parameter.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

Specifies the name of a VMM object.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Owner

Specifies the owner of a VMM object in the form of a valid domain user account.

  • Example format: -Owner "Contoso\PattiFuller"
  • Example format: -Owner "PattiFuller@Contoso"
Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

Type:Guid
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Release

Specifies a string that describes the release of a library resource. VMM automatically creates a release value for every resource imported into the library. After the resource has been imported, the string can be customized.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Script

Specifies a VMM script object.

Type:Script
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Scripts

Specifies an array of script objects.

Type:System.Collections.Generic.List`1[Microsoft.SystemCenter.VirtualMachineManager.Script]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SharePath

Specifies a path to a valid library share on an existing library server that uses a Universal Naming Convention (UNC) path.

Example format: -SharePath \\LibServer01\LibShare.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UserRole

Specifies a user role object.

Type:UserRole
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VMMServer

Specifies a VMM server object.

Type:ServerConnection
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

Outputs

Script

This cmdlet returns a Script object.

Notes

  • Requires a VMM script object, which can be retrieved by using the Get-SCScript cmdlet.