#powershell checks who has logged in to the remote machine
c:\>powershell query user /server:yourservername
-----------------------------------------------------------
output:
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
keninx rdp-tcp#84 7 Active 3:20 7/15/2020 7:31 AM
#powershell stop and start service on the remote machine
c:\>powershell $(get-service -ComputerName yourpcname -Name TermService).Stop()
c:\>powershell $(get-service -ComputerName yourpcname -Name TermService).Start()
----------------------------------------------------------
output: no
#powershell check if service is running
c:\>powershell get-service -ComputerName yoursrvname -Name TermService
---------------------------------------------------------
output:
Status Name DisplayName
------ ---- -----------
Running TermService Remote Desktop Services
#powershell check if software installed
gmwi win32_product -Filter {Name like "%whaterver%"} -ComputerName yourservername
---------------------------------------------------------
output:
IdentifyingNumber : {0364306B-8F28-4751-A2A2-271C25254E6C}
Name : SFT SoftName v7.0
Vendor : SFT
Version : 7.0.9.1
Caption : SFT SoftName v7.0
get resources on remote machine
Get-Counter -ComputerName expcj0079 '\Process(*)\% Processor Time' `
>> | Select-Object -ExpandProperty countersamples `
>> | Select-Object -Property instancename, cookedvalue `
>> | Sort-Object -Property cookedvalue -Descending | Select-Object -First 20 `
>> | ft InstanceName,@{L='CPU';E={($_.Cookedvalue/100).toString('P')}} -AutoSize
rename files in directory
get-childitem -filter "*.txt" | rename-item -newname{$_.name -replace 'mach', 'bach'}
search text in the files in the directory
Get-ChildItem . -recurse | select-string -pattern LrsCleanup