Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
# 基本認証の機能をインストール
PS C:\Users\Administrator> Install-WindowsFeature Web-Basic-Auth
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {Basic Authentication}
# IIS 再起動
PS C:\Users\Administrator> Restart-Service W3SVC
PS C:\Users\Administrator> Get-Website
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Default Web Site 1 Started %SystemDrive%\inetpub\wwwroot http *:80:
RX-7.srv.world 2 Started C:\inetpub\newsite http *:80:RX-7.srv.world
https *:443:rx-7.srv.world sslFlags=0
# [auth_basic] フォルダー作成
PS C:\Users\Administrator> New-Item -ItemType Directory -Path "IIS:\Sites\RX-7.srv.world\auth_basic"
Directory: WebAdministration::\\RX-7\Sites\RX-7.srv.world
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 9/9/2019 7:21 PM auth_basic
# 匿名認証を無効化
PS C:\Users\Administrator> Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/anonymousAuthentication' -Location "RX-7.srv.world/auth_basic" -Name enabled -Value False
# 基本認証を有効化
PS C:\Users\Administrator> Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/basicAuthentication' -Location "RX-7.srv.world/auth_basic" -Name enabled -Value True
# Web サイト再起動
PS C:\Users\Administrator> Restart-WebItem -PSPath 'IIS:\Sites\RX-7.srv.world'
# テストページ作成
PS C:\Users\Administrator> Write-Output "Basic Authentication Test Page" | Out-File C:\inetpub\newsite\auth_basic\index.html -Encoding Default
# アクセスして動作確認 ⇒ [-u (ユーザー名)]
PS C:\Users\Administrator> curl.exe -u Serverworld https://rx-7.srv.world/auth_basic/
Enter host password for user 'Serverworld': # ユーザーのパスワード
Basic Authentication Test Page
|