Enable-ASAppServiceAutoStart

Enable-ASAppServiceAutoStart

Enables auto-start for a service. This operation adds a serviceAddress line for the service to the serviceAutoStart attribute in the application Web.config file. To be able to enable or disable auto-start for a service, you must be using the Windows 7 or Windows Server 2008 R2 operating system. The Enable-ASAppServiceAutoStart cmdlet is executed when you click Enable to enable auto-start for the service in the Availability tab of the Configure WF and WCF for Application dialog box. Auto-start can only be configured for a service on Windows 7 or Windows Server 2008 R2 and above. You can indicate the service to enable auto-start for by using the –SiteName –VirtualPath parameter set, the –Uri parameter set, or the ServiceObject parameter. To enable auto-start for a service, the serviceAutoStartEnabled attribute in the applicationhost.config file for the application including that service must be set to “true” and the serviceStartupMode element in applicationhost.config must be set to “Custom”. To enable auto-start for the application and set serviceStartupMode to “custom”, execute the Set-ASApplication cmdlet with the –AutoStartMode parameter set to “-Custom”. If the cmdlet detects that the application is not set to auto-start, the cmdlet will emit a non-terminating error with a message that the application must be enabled for auto-start first. If the cmdlet detects that the application is set to auto-start with serviceStartupMode=”all”, the cmdlet will emit a warning that the effect of the cmdlet is ignored until you set serviceStartupMode=”custom”.

Syntax

Parameter Set: SiteNameAndVirtualPath
Enable-ASAppServiceAutoStart [-SiteName] <String> [-VirtualPath] <String> [-Confirm] [-WhatIf] [ <CommonParameters>]


Parameters

-ServiceObject<ServiceInfo>

The name of the ServiceObject, which specifies that the cmdlet will operate on that service. This parameter is typically used to pipe the output of the Get-ASAppService cmdlet to a cmdlet containing the ServiceObject parameter.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

-SiteName<String>

The name of a Web site, as defined in the IIS Connections pane, which specifies that the cmdlet will operate at the scope of a service contained within that site. To the SiteName parameter, you must add the VirtualPath parameter that identifies a service contained within the site. The virtual path must include the name of the application, a forward slash, and the name of the .svc file or .xamlx file for the service. The leading "/" character in the virtual path is optional. If you use the SiteName parameter, do not use the Uri parameter.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

-Uri<Uri>

A URI for a service, which specifies that the cmdlet will operate at that scope. If you use the Uri parameter, do not use the SiteName and VirtualPath parameter set.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

-VirtualPath<String>

The virtual path for a service, as defined in the IIS Manager Connections pane, which specifies that the cmdlet will operate at the scope of the service. You must add the VirtualPath parameter to the SiteName parameter, using SiteName to identify the site that the service is included in. The leading "/" character in the virtual path is optional. For a service, the virtual path includes the name of the application, a forward slash, and the name of the .svc file or .xamlx file for the service. If you use the SiteName and VirtualName parameter set, do not use the Uri parameter.


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

-Confirm

Prompts you for confirmation before executing the command.


Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Describes what would happen if you executed the command without actually executing the command.


Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

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.

  • None


Outputs

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

  • ServiceAutoStartInfo


Examples

EXAMPLE 1

Enables auto-start for the svc1 service in the App1 application of the Default Web Site.


Enable-ASAppServiceAutoStart -SiteName “Default Web Site” -VirtualPath “/App1/svc1.svc”

EXAMPLE 2

Enables auto-start for all services under a common Web site (My Web Site).


Get-ASApplication –SiteName “My Web Site” | Get-ASAppService | Enable-ASAppServiceAutoStart
Show: