My recipe to:
- Request Just in time virtual machine (VM) access
- Start a PowerShell remote session to the VM
Start a Powershell CLI with elevated rights:
Enable-PSRemoting -SkipNetworkProfileCheck -Force
Set-NetFirewallRule –Name "WINRM-HTTP-In-TCP-PUBLIC" –RemoteAddress 172.0.0.0/8
Start a PowerShell CLI with elevated rights:
Install-Module Azure-Security-Center -Force
Start-Service WinRM; Get-Service WinRM
Set-Item WSMan:\localhost\Client\TrustedHosts -value 172.* -Force; Get-Item WSMan:\localhost\Client\TrustedHosts
sc.exe config WinRM start= "delayed-auto"
Start a new PowerShell CLI:
Login-AzureRmAccount
Import-Module Azure-Security-Center
# powershell remoting over HTTP TCP/5985
Invoke-ASCJITAccess -ResourceGroupName XXXRG -VM TEST-IIS-VM -Port 5985 -Hours 1
$DNS = Resolve-DnsName -Name MyServer.MyDomain.Tech
Enter-PSSession -ComputerName $DNS.IPAddress -Credential $cred
$TargetSession = New-PSSession -ComputerName HALOMEM03
Copy-Item -ToSession $TargetSession -Path D:\tcping64.exe -Destination d:\ -Recurse
dism /online /enable-feature /featurename=File-Services
todo...
- Open port 5986 on the server
- request access to port 5986
- create certificate on the server and import in locally