ConnectWise Control Remote Powershell Commands PT 2

Welcome to the ConnectWise Control Remote Powershell Commands PT 2. They are my other go to remote commands. Some commands will need extra configuration or tweaking depending on your environment. The others are cut and paste. Enjoy!

PowerShell & Command Prompt Commands

The commands are either PowerShell (#!ps) or Command Prompt (#!cmd) commands. There are a couple attributes that affect how the commands respond.

#MaxLength - The max length of output characters. Some may need to be larger due to amount of output data.
#TimeOut - The period of time the command can run and will be terminated after the max has been hit. Most commands are quick to respond.

SUCCESS or FAILURE
The Command Prompt commands should work fine however the PowerShell commands may fail due to the set level of running commands remote.
"ps cannot be loaded because the execution of scripts is disabled or restricted on this system."
Let's set the execution policy.

Set Execution Policy

#!ps
#maxlength=50000
#timeout=9000000
Set-ExecutionPolicy Unrestricted

Ping

#!ps
#maxlength=50000
#timeout=9000000
ping Google.com

Trace Route

#!ps
#maxlength=50000
#timeout=9000000
tracert Google.com

Install PowerShellGet

#!ps
#maxlength=50000
#timeout=9000000
Install-Module -Name PowerShellGet -Force

Get Execution Policy

#!ps
#maxlength=50000
#timeout=9000000
Get-ExecutionPolicy

Get Package Providers

#!ps
#maxlength=50000
#timeout=9000000
Get-PackageProvider -ListAvailable

Find Port Owning Process

#!ps
#maxlength=50000
#timeout=9000000
Get-Process -Id (Get-NetTCPConnection -LocalPort <PORT>).OwningProcess
Get-Process -Id (Get-NetUDPEndpoint -LocalPort <PORT>).OwningProcess

Misc Power Commands

#!ps
#maxlength=50000
#timeout=9000000
powercfg -LIST
 
#!ps
#maxlength=50000
#timeout=9000000
gpresult /Scope User /v
 
#!ps
#maxlength=50000
#timeout=9000000
powercfg /sleepstudy
 
#!ps
#maxlength=50000
#timeout=9000000
powercfg -aliases

Windows Defender Commands

#!ps
#maxlength=50000
#timeout=9000000
Get-Command -Module Defender
 
#!ps
#maxlength=50000
#timeout=9000000
Update-MpSignature
 
#!ps
#maxlength=50000
#timeout=9000000
Get-MpComputerStatus
 
#!ps
#maxlength=50000
#timeout=9000000
Get-service Windefend
 
#!ps
#maxlength=50000
#timeout=9000000
Start-MpScan -ScanType QuickScan

Enable Linked Connections

#!ps
#maxlength=50000
#timeout=9000000
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -PropertyType DWORD -Name 'EnableLinkedConnections' -Value 1

Get App Packages

#!ps
#maxlength=50000
#timeout=9000000
Get-AppxPackage

List Fonts

#!ps
#maxlength=50000
#timeout=9000000
Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'

Sophos Scan & Update

#!ps
#maxlength=50000
#timeout=9000000
$Sophos = "C:\Program Files (x86)\Sophos\Sophos Anti-Virus\sav32cli.exe"
$Arguments = "-remove"
Start-Process $Sophos -ArgumentList $Arguments -NoNewWindow -Wait
 
#!ps
#maxlength=50000
#timeout=9000000
$sophos = New-Object -ComObject "activelinkclient.clientupdate.1"
$sophos.updatenow($true,1)

Rename Workstation

#!ps
#maxlength=50000
#timeout=9000000
WMIC computersystem where caption='OLDName' rename NEWNAME

Enable TLS in Commands

#!ps
#maxlength=50000
#timeout=9000000
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
<Commands>

Conclusion

There you go! These are the remote commands that help me with my day to day MSP life.


Questions, comments, want to point out errors or just want to say Hi? Please fill out the contact form below.

4/22/2021 - ConnectWise Control Remote PowerShell Commands
4/25/2021 - ConnectWise Control Remote PowerShell Commands PT 2

First Name:

About Wade

I am dedicated and accomplished application developer and multi-hat information system administrator and manager. Extensive background with the full lifecycle of hardware with systems, devices, networks, databases and software development while ensuring optimal performance.
 
WadeBach.com

Last Name:
Email:
Message: