Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit 985b0f5

Browse files
Add example for running app pool as a specific user
1 parent 369dda0 commit 985b0f5

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

‎examples/10-SpecificUser/IIS.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -----------------------------------------------------------------------------
2+
# Setup
3+
# -----------------------------------------------------------------------------
4+
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
5+
cd $here
6+
7+
. ..\_Setup.IIS.ps1
8+
9+
# -----------------------------------------------------------------------------
10+
# Example
11+
# -----------------------------------------------------------------------------
12+
Import-Module IISAdministration
13+
14+
$manager = Get-IISServerManager
15+
$pool = $manager.ApplicationPools.Add("My Pool")
16+
$pool.ProcessModel.IdentityType = "SpecificUser"
17+
$pool.ProcessModel.Username = "My User"
18+
$pool.ProcessModel.Password = "Password"
19+
20+
$manager.CommitChanges()
21+
22+
# -----------------------------------------------------------------------------
23+
# Assert
24+
# -----------------------------------------------------------------------------
25+
26+
if ((Get-IISAppPool -Name "My Pool") -eq $null) { Write-Error "My Pool not found" }
27+
28+
# -----------------------------------------------------------------------------
29+
# Clean up
30+
# -----------------------------------------------------------------------------
31+
32+
. ..\_Teardown.IIS.ps1
33+
34+
$manager = Get-IISServerManager
35+
$manager.ApplicationPools["My Pool"].Delete()
36+
$manager.CommitChanges()

‎examples/10-SpecificUser/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Changing logging settings
2+
3+
HTTP request logging is provided by IIS and can be specified server-wide or on an individual site level. Applications and virtual directories can disable logging, but they can't do any logging of their own. The examples below show how to set logging at the site level.
4+
5+
Logging settings are stored in `applicationHost.config` underneath the site:
6+
7+
```xml
8+
<system.applicationHost>
9+
<!-- ... -->
10+
<sites>
11+
<site name="Default Web Site" id="1">
12+
<bindings>
13+
<binding protocol="http" bindingInformation="*:80:" />
14+
</bindings>
15+
<logFile logFormat="IIS" directory="%SystemDrive%\inetpub\logs\LogFiles1" period="Hourly" />
16+
</site>
17+
<siteDefaults>
18+
<logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
19+
<traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
20+
</siteDefaults>
21+
<!-- ... -->
22+
```

‎examples/10-SpecificUser/Web.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -----------------------------------------------------------------------------
2+
# Setup
3+
# -----------------------------------------------------------------------------
4+
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
5+
cd $here
6+
7+
. ..\_Setup.Web.ps1
8+
9+
Remove-Item -Path "IIS:\AppPools\My Pool" -Recurse -Force -ErrorAction SilentlyContinue
10+
11+
# -----------------------------------------------------------------------------
12+
# Example
13+
# -----------------------------------------------------------------------------
14+
15+
Import-Module WebAdministration
16+
17+
New-Item -Path "IIS:\AppPools" -Name "My Pool" -Type AppPool
18+
19+
$identity = @{ `
20+
identitytype="SpecificUser"; `
21+
username="My Username"; `
22+
password="My Password" `
23+
}
24+
Set-ItemProperty -Path "IIS:\AppPools\My Pool" -name "processModel" -value $identity
25+
26+
# -----------------------------------------------------------------------------
27+
# Assert
28+
# -----------------------------------------------------------------------------
29+
30+
if ((Get-WebAppPoolState -Name "My Pool") -eq $null) { Write-Error "Pool not found" }
31+
32+
# -----------------------------------------------------------------------------
33+
# Clean up
34+
# -----------------------------------------------------------------------------
35+
36+
. ..\_Teardown.Web.ps1
37+
38+
Remove-Item -Path "IIS:\AppPools\My Pool" -Recurse -Force

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /