-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPCServerportChecker.ps1
More file actions
35 lines (20 loc) · 1.12 KB
/
RPCServerportChecker.ps1
File metadata and controls
35 lines (20 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Script Written by Drew Burgess 12/19/2021
Function TEST-RPCSERVER {
cls
$LocalHost = $env:COMPUTERNAME
$theinfo = "$LocalHost"
[System.Int16]$port = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("MTM1"))
$rpcsscheckport = Test-NetConnection -ComputerName $theinfo -Port $port -ErrorAction Ignore | Select TcpTestSucceeded
$rpcstatus = Invoke-Command -ComputerName $theinfo -ScriptBlock { get-service -Name "rpcss" | Select Status }
If (($rpcsscheckport -and "True") -and (($rpcstatus) -and "Running")) {
Write-Host "`nRPC Server is running on remote host : $theinfo" -ForegroundColor Green -BackgroundColor Black
}
Else {
# If RPC port is open
If ($rpcsscheckport -and "True") {
Write-Host "`nStarting Rpc Server on remote host " -ForegroundColor DarkYellow -BackgroundColor Black
Invoke-Command -ComputerName $theinfo -ScriptBlock { Restart-Service "RpcSs" } -WarningAction Ignore -ErrorAction Ignore
}
}
}
TEST-RPCSERVER