PowerShell: Install TightVNC on Windows via CLI

Install VNC Server on the Remote Windows:
# Access Remote Server via WinRM
$SHERVERNAME = "SHERVER007"
$winRMHttp=5985
$winRMHttps=5986

# Check to ensure that port 5986 is operational
Test-NetConnection $SHERVERNAME -port $winRMHttp
Test-NetConnection $SHERVERNAME -port $winRMHttps

# Connect to remote server's WinRM instance
Enter-PSSession -ComputerName $SHERVERNAME -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck) #optional: -Credential (Get-Credential)
# Install Chocolatey if it's not already available
if (!(Get-Command choco.exe -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))}
# Install TightVNC without Password Authentication (defer to Console AD Auths)
choco install tightvnc -y --installArguments 'SET_USEVNCAUTHENTICATION=1 VALUE_OF_USEVNCAUTHENTICATION=0'
Install VNC Viewer on the client:
# Install only VNC Viewer
choco install tightvnc -ia "ADDLOCAL=Viewer"

Leave a Reply

Your email address will not be published. Required fields are marked *