Last active
January 29, 2021 14:11
-
-
Save ay65535/4c0874c348913f94f5a21e9fb627c2e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ホスト要件 # https://docs.ansible.com/ansible/2.9_ja/user_guide/windows_setup.html#id1 | |
# Windows version | |
Get-WmiObject Win32_OperatingSystem | |
# PowerShell 3.0+ supported | |
$PSVersionTable | |
# .NET 4.0+ supported | |
# https://stackoverflow.com/a/3495491 | |
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | | |
Get-ItemProperty -name Version,Release -EA 0 | | |
Where { $_.PSChildName -match '^(?!S)\p{L}'} | | |
Select PSChildName, Version, Release | |
# WinRM の設定 # https://docs.ansible.com/ansible/2.9_ja/user_guide/windows_setup.html#id3 | |
$url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1" | |
$file = "$env:temp\ConfigureRemotingForAnsible.ps1" | |
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file) | |
& $file | |
# WinRM サービスで実行している現在のリスナーを表示 | |
$info = winrm enumerate winrm/config/Listener | |
$info | |
# CertificateThumbprint を取得 | |
$m = $info | sls 'CertificateThumbprint = ([A-Z\d]+)' | |
$thumbprint = $m.Matches.Groups[1].Value | |
# 証明書自体の詳細を取得 | |
Get-ChildItem -Path cert:\LocalMachine\My -Recurse | Where-Object { $_.Thumbprint -eq $thumbprint } | Select-Object * | |
# WinRM リスナーの設定 | |
# HTTP の場合 | |
# winrm quickconfig | |
# HTTPS の場合 | |
# winrm quickconfig -transport:https | |
# PowerShell を使用 | |
$selector_set = @{ | |
Address = "*" | |
Transport = "HTTPS" | |
} | |
$value_set = @{ | |
CertificateThumbprint = $thumbprint | |
} | |
New-WSManInstance -ResourceURI "winrm/config/Listener" -SelectorSet $selector_set -ValueSet $value_set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment