Get-SCScript

Get-SCScript

Gets script objects from the VMM library.

構文

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

詳細説明

The Get-SCScript cmdlet gets script objects from the Virtual Machine Manager (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. 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.

パラメーター

-All

Indicates that this cmdlet 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.

エイリアス

none

必須?

false

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

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.

エイリアス

none

必須?

true

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-ID<Guid]>

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

エイリアス

none

必須?

false

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-Name<String>

Specifies the name of a VMM object.

エイリアス

none

必須?

true

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

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.

エイリアス

none

必須?

false

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-VMMServer<ServerConnection>

Specifies a VMM server object.

エイリアス

none

必須?

false

位置は?

named

既定値

none

パイプライン入力を許可する

True (ByValue)

ワイルドカード文字を許可する

false

<CommonParameters>

このコマンドレットは次の共通パラメーターをサポートします。-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer、-OutVariable.詳細については、以下を参照してください。 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。

入力

入力型は、コマンドレットにパイプできるオブジェクトの型です。

出力

出力型は、コマンドレットによって生成されるオブジェクトの型です。

  • Script

Example 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.

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

Example 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.

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

Example 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.

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" }

Example 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 then 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.

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

Example 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 then stores the object in the $Script variable.

The second command uses the Call operator (&) to run the script stored in $Script. For more information, type Get-Help about_Operators.

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 is not:

1. Run the VMM command shell as an Administrator.

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

関連トピック

Get-SCVirtualDiskDrive

Remove-SCScript

Set-SCScript