Welcome to the ConnectWise Control Remote Powershell Commands PT 4. 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.

Check Execution Policy

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

Set Execution Policy to Unrestricted

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

Lower PowerShell Priority

#!ps
#maxlength=50000
#timeout=9000000
$process = Get-Process -Id $pid;
$process.PriorityClass = 'BelowNormal';
<Commands>

Lower Executable Priority and CPU Affinity

#!ps
#maxlength=50000
#timeout=9000000
$process = Get-Process -Id $pid;
$process.PriorityClass = 'BelowNormal';
$SFCOpt="/scannow";
Start-Process -FilePath "${env:Windir}\System32\SFC.EXE" -ArgumentList $SFCOpt -Verb RunAs;
 
Run the executable then run this command.
 
#!ps
#maxlength=50000
#timeout=9000000
Get-Process TiWorker,TrustedInstaller | ForEach-Object { $_.ProcessorAffinity=2
$_.PriorityClass='BelowNormal'};


Disk Clean Up

#!ps
#maxlength=50000
#timeout=9000000
$process = Get-Process -Id $pid;
$process.PriorityClass = 'BelowNormal';
Get-ChildItem "C:\Windows\SoftwareDistribution\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
Get-ChildItem "C:\Windows\prefetch\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
Get-ChildItem "C:\Users\*\AppData\Local\Temp\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
Get-ChildItem "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
Get-ChildItem "C:\Windows.old\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
Get-ChildItem "C:\Windows10Upgrade\*" -Recurse -Force -verbose -ErrorAction SilentlyContinue | Remove-Item -Force -Verbose -Recurse -ErrorAction SilentlyContinue;
Get-ChildItem -Path 'C:\$Recycle.Bin' -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue;

Show Product Version

#!ps
#maxlength=50000
#timeout=9000000
Get-Process -Name "*office*" | Format-list -Property ProductVersion
 

List Memory Information

#!ps
#maxlength=50000
#timeout=9000000
wmic MEMORYCHIP get BankLabel,DeviceLocator,MemoryType,TypeDetail,Capacity,Speed
 

List Memory Capacity

#!ps
#maxlength=50000
#timeout=9000000
Get-WmiObject Win32_PhysicalMemory | Select-Object Capacity
 

List Process Information by Memory Consumption

#!ps
#maxlength=50000
#timeout=9000000
Get-Process | Sort-Object -Descending WS
 

Show Camera Information

#!ps
#maxlength=50000
#timeout=9000000
Get-WmiObject Win32_PnPEntity | where {$_.caption -match 'camera'}
 

Get Hard Drive Information

#!ps
#maxlength=50000
#timeout=9000000
get-psdrive -psprovider filesystem;
 

List Start Up Programs

#!ps
#maxlength=50000
#timeout=9000000
wmic startup get caption,command
 

Check Disk Health

#!ps
#maxlength=50000
#timeout=9000000
GetPhysical-Disk
 

Check Disk Reliabilty

#!ps
#maxlength=50000
#timeout=9000000
GetPhysical-Disk | Get-StorageReliabilityCounter
 

List Plug and Play Devices

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

List USB Devices

#!ps
#maxlength=50000
#timeout=9000000
Get-PnpDevice -FriendlyName '*USB*'
 

List PNP Error Devices

#!ps
#maxlength=50000
#timeout=9000000
Get-PnpDevice -PresentOnly -Status ERROR,DEGRADED,UNKNOWN
 

Conclusion

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