Remove-SCScript

Remove-SCScript

Removes a script object from VMM.

構文

Parameter Set: Default
Remove-SCScript [-Script] <Script> [-Force] [-JobVariable <String> ] [-PROTipID <Guid]> ] [-RunAsynchronously] [-Confirm] [-WhatIf] [ <CommonParameters>]

詳細説明

The Remove-SCScript cmdlet removes one or more script objects from the Virtual Machine Manager (VMM) library and deletes the corresponding script file on the library server.

If the script is attached to a template or hardware profile, and if you do not use the Force parameter, VMM lists the container that contains the script and prompts you to confirm that you want to remove the script:

-- If you reply Yes, VMM removes the association between the script and the container to which it is attached, and then deletes the script object from VMM.

-- If you reply No, the operation is cancelled.

This cmdlet returns the object upon success, with the property MarkedForDeletion set to TRUE, or returns an error message upon failure.

パラメーター

-Force

Forces the operation to complete.

For example:

- Remove-SCSCVMHost -Force

Forces the removal of a host object from the VMM database.

- Stop-SCVirtualMachine -Force

Stops a virtual machine.

エイリアス

none

必須?

false

位置は?

named

既定値

none

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

false

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

false

-JobVariable<String>

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

エイリアス

none

必須?

false

位置は?

named

既定値

none

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

false

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

false

-PROTipID<Guid]>

Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

エイリアス

none

必須?

false

位置は?

named

既定値

none

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

false

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

false

-RunAsynchronously

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

エイリアス

none

必須?

false

位置は?

named

既定値

none

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

false

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

false

-Script<Script>

Specifies a VMM script object.

エイリアス

none

必須?

true

位置は?

1

既定値

none

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

True (ByValue)

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

false

-Confirm

コマンドレットを実行する前に、ユーザーに確認を求めます。

必須?

false

位置は?

named

既定値

false

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

false

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

false

-WhatIf

コマンドレットを実行するとどのような結果になるかを表示します。コマンドレットは実行されません。

必須?

false

位置は?

named

既定値

false

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

false

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

false

<CommonParameters>

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

入力

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

出力

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

Example 1: Remove a script object and delete the corresponding script file

The first command gets the script object named AddHost.ps1 from the VMM library on VMMServer01, and then stores the object in the array named $Scripts. More than one file with the same name might exist if more than one container for scripts exists on the specified library server.

The second command counts the number of scripts in $Scripts and displays the results.

The third command passes each script object in $Scripts to the Select-Object cmdlet, which selects the name and share path for each script in the array. The command then passes these results to the Format-List cmdlet to display each script name, and its share path. For more information, type Get-Help Select-Object and Get-Help Format-List.

The last command deletes the first object in the $Scripts array. The command specifies the Force parameter to ensure that the script object is removed from the VMM database and that the corresponding script file is deleted from the file system on the library server.

PS C:\> $Scripts = @(Get-SCScript -VMMServer "VMMServer01.Contoso.com" | where { $_.LibraryServer.Name -eq "LibraryServer01.Contoso.com" -and $_.Name -eq "AddHost.ps1"} )
PS C:\> $Scripts.Count
PS C:\> $Scripts | select Name,SharePath | Format-List
PS C:\> Remove-SCScript -Script $Scripts[0] -Force

Example 2: Remove multiple scripts from the library

The first command gets all script objects whose names include the string Sysprep from VMMServer01, and then stores these objects in the array named $Scripts.

The second command passes each script object in $Scripts to Remove-SCScript, which removes each script object from the library and deletes each corresponding script file from the file system on the library server.

The second command specifies the Confirm parameter. The command prompts you to confirm that you do want to remove these scripts. You have the option to confirm the deletion of all scripts at once or to confirm the deletion of each script one-by-one.

PS C:\> $Scripts = Get-SCScript -VMMServer "VMMServer01.Contoso.com" | where { $_.Name -match "Sysprep" }
PS C:\> $Scripts | Remove-SCScript -Confirm

関連トピック

Get-SCScript

Set-SCScript