# ์๊ฒฉ ์คํ
# ์๊ฒฉ
http://lab.gamecodi.com/board/zboard.php?id=GAMECODILAB_QnA_etc&no=5258&z=
# ์๊ฒฉ๊ด๋ จ ์ค๋ฅ ์ฐธ์กฐ
https://m.blog.naver.com/PostView.nhn?blogId=sung487&logNo=221042683798&proxyReferer=https%3A%2F%2Fwww.google.com%2F
# ์๊ฒฉ PowerShell :
1) Enable-PSRemoting
2)Azure์ ์๊ฒฉ๋ฐฉํ๋ฒฝ์ ์ธ๋ฐ์ด๋ ํฌํธ 5985,5986 ๊ฐ๋ฐฉ
# ๋ก์ปฌ PowerShell:
1)winrm quickconfig --force
2)winrm get winrm/config/client
3)ํน์ IP์ ์ ์ํ๋ ๊ฒ์ ํ์ฉ
-- ํน์ IPํ์ฉ
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "52.141.18.204"
-- ์ ์ฒด ํ์ฉ
Set-Item WSMan:\localhost\Client\TrustedHosts -Value *
4)์๋์ ์์ ํ๊ธฐ ์ํ ์ธํ
$MyCredential = Get-Credential "f5074"
$MyPassword = Read-Host "Password" -AsSecureString | ConvertFrom-SecureString
$MyPassword = $MyPassword | ConvertTo-SecureString
$ObjectTypeName = "System.Management.Automation.PSCredential"
$MyCredential = New-Object -TypeName $ObjectTypeName -ArgumentList "f5074",$MyPassword
5)
-- ์ง์ ์ ์ํด์ ํ์ธ
Enter-PSSession -ComputerName "52.141.18.204" -Credential $MyCredential
-- ํน์ ๋ช
๋ น์ด๋ง ์คํ
Invoke-Command -ComputerName "52.141.18.204" -credential $MyCredential -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'taskkill /im node.exe /f'"}
Invoke-Command -ComputerName "52.141.18.204" -credential "f5074" -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\inetpub\ftproot\stop_sv.bat'"}
--Commit&Push git
Invoke-Command -ComputerName "52.141.18.204" -credential "f5074" -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\inetpub\ftproot\start_commit_git.bat'"}
--pull git
Invoke-Command -ComputerName "52.141.18.204" -credential "f5074" -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\inetpub\ftproot\start_pull_git.bat'"}
-- ์๋ฒ ์ข
๋ฃ
Invoke-Command -ComputerName "52.141.18.204" -credential "f5074" -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\inetpub\ftproot\stop_sv.bat'"}
Invoke-Command -ComputerName "52.141.18.204" -credential $MyCredential -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'taskkill /im node.exe /f'"}
-- ์๋ฒ ์ฌ์์
Invoke-Command -ComputerName "52.141.18.204" -credential "f5074" -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\inetpub\ftproot\start_sv.bat'"}
-- ํ์ธ
f5074.koreacentral.cloudapp.azure.com:4200
# ๋ณด์ ๊ทธ๋ฃน ๊ท์น์ ์ํด ์ฐจ๋จ๋ ๋คํธ์ํฌ ์ฐ๊ฒฐ: DefaultRule_DenyAllInBound
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
# references
https://community.spiceworks.com/topic/2242211-azure-nsg-rdp
https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.9.0