Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Get-SCScript

Updated: November 1, 2013

Applies To: System Center 2012 R2 Virtual Machine Manager

Get-SCScript

Gets script objects from the VMM library, which allows you to view or edit any script, or to view, edit, or run a Windows PowerShell script (if you have appropriate permissions).

Syntax

Parameter Set: All
Get-SCScript [-All] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: EquivalentResourceParamSet
Get-SCScript -FamilyName <String> [-Release <String> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: ID
Get-SCScript [-ID <Guid> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: NameParamSet
Get-SCScript -Name <String> [-VMMServer <ServerConnection> ] [ <CommonParameters>]




Detailed Description

The Get-SCScript cmdlet gets script objects from the Virtual Machine Manager (VMM) library. The script file that a script object represents is stored in the file system on a library server. Typically, these scripts are either Windows PowerShell scripts or answer file scripts (including Sysprep.inf and Unattend.xml files, which contain the inputs required for the Windows Setup program).

As illustrated in the examples, you can use Get-SCScript not only to retrieve script objects but also (if you have appropriate permissions) to view the contents of a script or to edit a script. In addition, you can run the script if the following are true: 1) the script is a Windows PowerShell script, 2) scripting is enabled on your server, and 3) you have appropriate permissions (see example 5).

For information about enabling Windows PowerShell scripting on your server, type: "Get-Help about_Signing", "Get-Help Get-ExecutionPolicy -detailed", and "Get-Help Set-ExecutionPolicy -detailed".

Parameters

-All

Retrieves a full list of all subordinate objects independent of the parent object. For example, the command Get-SCVirtualDiskDrive -All retrieves all virtual disk drive objects regardless of the virtual machine object or template object that each virtual disk drive object is associated with.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FamilyName<String>

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.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ID<Guid>

Specifies the numerical identifier (as a globally unique identifier, or GUID) for a specific object.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name<String>

Specifies the name of a VMM object.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Release<String>

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VMMServer<ServerConnection>

Specifies a VMM server object.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Script

Examples

1: Get all scripts stored on all VMM library servers.

This command gets all script objects stored in library shares in the VMM library on VMMServer01, and then displays information about these scripts to the user.


PS C:\> Get-SCScript -VMMServer "VMMServer01.Contoso.com"

2: Display specified information about all scripts on a library server.

This command gets all script objects stored on LibraryServer01 and displays the name, library server, and share path for these scripts to the user.


PS C:\> Get-SCScript -VMMServer "VMMServer01.Contoso.com" | where { $_.LibraryServer.Name -eq "LibraryServer01.Contoso.com" } | Format-List -Property Name, LibraryServer, SharePath

3: Get all scripts with a specific name on any VMM library server.

This command gets the answer file script objects named Sysprep.inf that are stored on any library server on VMMServer01.

NOTE: By default, the name of a script object in the VMM library is the same name (including the file extension) as the name of the actual script file on the library server.


PS C:\> Get-SCScript -VMMServer "VMMServer1.Contoso.com" | where { $_.Name -eq "Sysprep.inf" }

4: View a script that is stored in the VMM library.

The first command gets the script object named "SummarizeVMMInfo.ps1" from the VMM library and stores the object in the $Script variable.

The second command uses Notepad to open the script so that you can view its contents (if you have the appropriate permissions to read the script).

NOTE: If you have appropriate write permissions, you can also edit the script and save the new version.


PS C:\> $Script = Get-SCScript | where { $_.Name -eq "SummarizeVMMInfo.ps1"}PS C:\> Notepad.exe $Script.SharePath

5: Run a Windows PowerShell script that is stored in the VMM library.

The first command gets the script object named "SummarizeVMMInfo.ps1" from the VMM library and stores the object in the$Script variable.

The second command uses the "&" operator to run the script stored in $Script.

To run a Windows PowerShell script stored in a VMM library share, you must ensure the following:

- You have read and execute permissions on the script file.

- You are member of the VMM Administrators user role.



- You have permissions to access the VMM library share.



- Windows PowerShell scripting is enabled. If it isn't:

1. Run the VMM command shell as an Administratorr.

2. Use the Set-ExecutionPolicy cmdlet to set the execution

policy to the appropriate level for your environment.

For more information, type:

Get-Help about_Signing

Get-Help Get-ExecutionPolicy -detailed

Get-Help Set-ExecutionPolicy -detailed


PS C:\> $Script = Get-SCScript | where { $_.Name -eq "SummarizeVMMInfo.ps1" }PS C:\> &$Script.SharePath

Related topics

 
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.