PowerShell script to test prerequisites for deploying agents via the console on a Windows device
Before deploying Snow Windows agents via the console, the target Windows device must allow remote communication over specific ports and have required services enabled. The following PowerShell script checks:
-
Whether the required UDP and TCP ports are open (135, 137, 138, 139, 445).
-
Whether File and Printer Sharing is enabled.
-
Whether the Remote Procedure Call (RPC) service is running.
Run this script in an elevated PowerShell session to confirm prerequisites are met before attempting deployment.
<#
Description : Test prerequisites required to deploy agents via console.
.NOTES
Version: 1.0
Author: Julian Dalley
Creation Date: 2024 04 23
Purpose/Change: Check that the prerequisites for deploying snow Windows agents via the console are met.
Reference : https://docs.snowsoftware.com/snow-inventory-server/en/UUID-eecf54a4-28dc-3957-c0a5-56309d578da0.html
>>>RUN IN POWERSHELL ISE WITH ADMINISTRATOR PRIVILEDGES<<<
#>
# Function to check if a UDP port is open
function Test-UDPPort {
param (
[string]$computerName,
[int]$port
)
$udpClient = New-Object System.Net.Sockets.UdpClient
try {
$udpClient.Connect($computerName, $port)
return $true
}
catch {
return $false
}
finally {
$udpClient.Close()
}
}
# Function to check if a TCP port is open
function Test-TCPPort {
param (
[string]$computerName,
[int]$port
)
$tcpClient = New-Object System.Net.Sockets.TcpClient
try {
$tcpClient.Connect($computerName, $port)
return $true
}
catch {
return $false
}
finally {
$tcpClient.Close()
}
}
# Check UDP ports 137 and 138
$udpPorts = @(
@{Port=137;Description="UDP 137"},
@{Port=138;Description="UDP 138"}
)
foreach ($udpPort in $udpPorts) {
$isOpen = Test-UDPPort -computerName "localhost" -port $udpPort.Port
if ($isOpen) {
Write-Host -ForegroundColor Green "$($udpPort.Description) is open."
}
else {
Write-Host -ForegroundColor Red "$($udpPort.Description) is closed."
}
}
# Check TCP ports 139, 445, and 135 (RPC)
$tcpPorts = @(
@{Port=139;Description="TCP 139"},
@{Port=445;Description="TCP 445"},
@{Port=135;Description="TCP 135 (RPC)"}
)
foreach ($tcpPort in $tcpPorts) {
$isOpen = Test-TCPPort -computerName "localhost" -port $tcpPort.Port
if ($isOpen) {
Write-Host -ForegroundColor Green "$($tcpPort.Description) is open."
}
else {
Write-Host -ForegroundColor Red "$($tcpPort.Description) is closed."
}
}
# Check if file and printer sharing is enabled
$filePrinterSharing = Get-WmiObject -Class Win32_Share -Filter "Type = 0"
if ($filePrinterSharing) {
Write-Host -ForegroundColor Green "File and printer sharing is enabled."
}
else {
Write-Host -ForegroundColor Red "File and printer sharing is disabled."
}
# Check if RPC service is running
$rpcService = Get-Service -Name "RpcSs"
if ($rpcService.Status -eq "Running") {
Write-Host -ForegroundColor Green "RPC service is running."
}
else {
Write-Host -ForegroundColor Red "RPC service is not running."
}Was this helpful?
© 2026 Flexera. All rights reserved.