meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
windows:powershell:start [2026/06/11 15:47] titannetwindows:powershell:start [2026/06/15 13:51] (current) titannet
Line 10: Line 10:
 Get-Command -module ActiveDirectory  Get-Command -module ActiveDirectory 
 </code> </code>
 +
 +
 +<code powershell>
 +Get-Service "vm*" | Get-Member
 +
 +Stop-Process -Name notepad -Force
 +Get-Process | Select-Object Name,ID,CPU
 +
 +</code>
 +
 +
 +===== Enable rdp =====
 +
 +
 +<code>
 +# Warning
 +Clear-Host
 +Write-Output "Run this script on the computer you want to access via RDP"
 +Write-Output ""
 +
 +# Ask
 +Write-Output "Remote address can be an IP address or network with CIDR"
 +Write-Output "Example: 192.168.0.5 or 192.168.0.0/24"
 +Write-Output ""
 +$RemoteAddress = Read-Host "Remote Address"
 +Write-Output ""
 +
 +# Registry
 +Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server"-Name "fDenyTSConnections" -Value 0
 +Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows NT\Terminal Services\Client" -Name "fClientDisableUDP" -Value 0
 +Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Value 1
 +
 +# Firewall
 +New-NetFirewallRule -DisplayName "RDP (TCP)" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3389 -RemoteAddress $RemoteAddress -Profile Any -Enabled True | Out-Null
 +New-NetFirewallRule -DisplayName "RDP (UDP)" -Direction Inbound -Action Allow -Protocol UDP -LocalPort 3389 -RemoteAddress $RemoteAddress -Profile Any -Enabled True | Out-Null
 +
 +# Result
 +Write-Output "Done! Now restart the computer"
 +Write-Output ""
 +
 +</code>
 +
 +
 +===== Event Logs =====
 +
 +<code powershell>
 +Get-EventLog -LogName Application -Newest 50
 +
 +</code>
 +
 +
 +
 +===== Export data =====
 +
 +<code powershell>
 +Get-Process | Export-Csv -Path processes.csv
 +
 +</code>
 +
 +
 +===== Sorting & Filtering =====
 +
 +<code powershell>
 +Get-Process | Sort-Object -Property CPU
 +Get-Process | Where-Object { $_.CPU -gt 10 }
 +
 +</code>
 +
 +