Add-SCScriptCommand

将脚本命令添加到应用程序配置文件、应用程序部署或主机配置文件。

语法

Add-SCScriptCommand
   -ApplicationProfile <ApplicationProfile>
   [-Executable <String>]
   [-CommandParameters <String>]
   [-ScriptCommandSetting <SCScriptCommandSetting>]
   -ScriptType <ScriptCommandType>
   [-TimeoutSeconds <Int32>]
   [-StandardInput <String>]
   [-LibraryResource <CustomResource>]
   [-RunAsAccount <VMMCredential>]
   [-VMMServer <ServerConnection>]
   [-DeploymentOrder <Int32>]
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]
Add-SCScriptCommand
   -ApplicationDeployment <ApplicationDeployment>
   [-Executable <String>]
   [-CommandParameters <String>]
   [-ScriptCommandSetting <SCScriptCommandSetting>]
   -ScriptType <ScriptCommandType>
   [-TimeoutSeconds <Int32>]
   [-StandardInput <String>]
   [-LibraryResource <CustomResource>]
   [-RunAsAccount <VMMCredential>]
   [-VMMServer <ServerConnection>]
   [-DeploymentOrder <Int32>]
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]
Add-SCScriptCommand
   -PhysicalComputerProfile <PhysicalComputerProfile>
   [-Executable <String>]
   [-CommandParameters <String>]
   [-ScriptCommandSetting <SCScriptCommandSetting>]
   -ScriptType <ScriptCommandType>
   [-TimeoutSeconds <Int32>]
   [-StandardInput <String>]
   [-LibraryResource <CustomResource>]
   [-RunAsAccount <VMMCredential>]
   [-VMMServer <ServerConnection>]
   [-JobGroup <Guid>]
   [-DeploymentOrder <Int32>]
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]
Add-SCScriptCommand
   [-Executable <String>]
   [-CommandParameters <String>]
   [-ScriptCommandSetting <SCScriptCommandSetting>]
   -ScriptType <ScriptCommandType>
   [-TimeoutSeconds <Int32>]
   [-StandardInput <String>]
   [-LibraryResource <CustomResource>]
   [-RunAsAccount <VMMCredential>]
   [-VMMServer <ServerConnection>]
   [-JobGroup <Guid>]
   [-DeploymentOrder <Int32>]
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]

说明

Add-SCScriptCommand cmdlet 向应用程序配置文件、应用程序部署或主机配置文件添加脚本命令。 脚本命令允许管理员在部署和服务操作期间运行代码。

示例

示例 1:向应用程序配置文件添加脚本命令

PS C:\> $AppProfile = Get-SCApplicationProfile -Name "SvcWebAppProfile01"
PS C:\> $ScriptSetting = New-SCScriptCommandSetting -WorkingDirectory "Working_Folder_01"
PS C:\> Add-SCScriptCommand -ApplicationProfile $AppProfile -Executable "Startup.ps1" -ScriptType "PreInstall" -ScriptCommandSetting $ScriptSetting -TimeoutSeconds 120

第一个命令获取名为 SvcWebAppProfile01 的应用程序配置文件对象,并将对象存储在$AppProfile变量中。

第二个命令创建脚本命令设置对象,该对象将工作目录设置为 Payload,然后将该对象存储在$ScriptSetting变量中。

最后一个命令将预安装脚本命令添加到存储在 $AppProfile 中的应用程序配置文件。

参数

-ApplicationDeployment

指定应用程序部署对象。

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

-ApplicationProfile

指定应用程序配置文件对象。

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

-CommandParameters

指定脚本或可执行程序的参数。

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

-DeploymentOrder

指定计算机层、应用程序主机或应用程序部署的顺序。

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

-Executable

指定可执行程序的名称。

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

-JobGroup

在运行最后一个包含相同作业组标识符的命令之前,为作为集合运行的一系列命令指定标识符。

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

-JobVariable

指定跟踪作业进度,并将其存储在此参数命名的变量中。

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

-LibraryResource

指定存储在 Virtual Machine Manager (VMM) 库中的资源。

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

-PhysicalComputerProfile

指定用于将操作系统部署到计算机的配置文件。

Type:PhysicalComputerProfile
Aliases:VMHostProfile
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PROTipID

指定触发此操作 (PRO 提示) 的性能和资源优化提示的 ID。 此参数允许审核 PRO 提示。

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

-RunAsAccount

指定包含具有执行此操作权限的凭据的运行方式帐户。

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

-RunAsynchronously

指示作业以异步方式运行,以便控件立即返回到命令 shell。

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

-ScriptCommandSetting

指定脚本命令设置对象。

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

-ScriptType

指定脚本类型。 此参数的可接受值为:

  • PreInstall
  • PostInstall
  • SaveState
  • RestoreState
  • PreService
  • PostService
  • PreUninstall
  • PostUninstall
  • OrderedCommand
  • BareMetalPostWinPERegistration
  • OnProvisionFirst
  • OnProvisionRest
  • OnDeleteLast
  • OnDeleteRest
  • 安装
  • BareMetalPostDeployment
Type:ScriptCommandType
Accepted values:PreService, PostService, SaveState, RestoreState, PreInstall, PostInstall, PreUninstall, PostUninstall, OrderedCommand, BareMetalPostWinPERegistration, OnProvisionFirst, OnProvisionRest, OnDeleteLast, OnDeleteRest, Install, BareMetalPostConfiguration, BareMetalPostUnattend
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-StandardInput

指定要与脚本命令一起使用的标准输入信息的文件的路径。

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

-TimeoutSeconds

指定进程在超时前等待的时间量(以秒为单位)。

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

-VMMServer

指定 Virtual Machine Manager (VMM) 服务器对象。

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

输出

ScriptCommand

此 cmdlet 返回 ScriptCommand 对象。