Skip to content

DeadmanXXXII/Powershell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Powershell

Here is an extensive list of PowerShell commands.

Comprehensive List of PowerShell Commands

System Information and Management

  • Get detailed system information:

    Get-ComputerInfo
  • Get hardware information:

    Get-CimInstance -ClassName Win32_Processor
  • Get BIOS information:

    Get-CimInstance -ClassName Win32_BIOS
  • List environment variables:

    Get-ChildItem Env:
  • Get the last boot time:

    (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
  • List installed hotfixes:

    Get-HotFix
  • List all installed programs:

    Get-WmiObject -Class Win32_Product
  • Check system drive space:

    Get-PSDrive -PSProvider FileSystem

File and Directory Management

  • List files and directories:

    Get-ChildItem
  • Create a new directory:

    New-Item -Path "directoryname" -ItemType Directory
  • Delete a directory:

    Remove-Item -Path "directoryname" -Recurse -Force
  • Copy files:

    Copy-Item -Path "sourcefile" -Destination "destinationfile"
  • Move files:

    Move-Item -Path "sourcefile" -Destination "destinationfile"
  • Delete files:

    Remove-Item -Path "filename"
  • Search for files:

    Get-ChildItem -Recurse -Filter "filename"
  • Find files containing specific text:

    Select-String -Path *.* -Pattern "searchtext"
  • Get file or directory size:

    (Get-Item "filename").length
  • Get the last modified date of a file:

    (Get-Item "filename").LastWriteTime
  • Get the creation date of a file:

    (Get-Item "filename").CreationTime
  • Rename a file:

    Rename-Item -Path "oldname" -NewName "newname"

Network Commands

  • Ping a host:

    Test-Connection -ComputerName hostname
  • Trace route to a host:

    Test-NetConnection -ComputerName hostname -TraceRoute
  • Test network connection to a port:

    Test-NetConnection -ComputerName hostname -Port port
  • View routing table:

    Get-NetRoute
  • Flush DNS cache:

    Clear-DnsClientCache
  • Display network shares:

    Get-SmbShare
  • Get network adapter configuration:

    Get-NetAdapter
  • Get detailed IP configuration:

    Get-NetIPAddress
  • List DNS servers:

    Get-DnsClientServerAddress
  • Get firewall rules:

    Get-NetFirewallRule
  • Add a new firewall rule:

    New-NetFirewallRule -DisplayName "RuleName" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80

User and Group Management

  • List all users:

    Get-LocalUser
  • Add a new user:

    New-LocalUser -Name "username" -Password (ConvertTo-SecureString "password" -AsPlainText -Force) -FullName "User Full Name" -Description "User description"
  • Delete a user:

    Remove-LocalUser -Name "username"
  • Add a user to a group:

    Add-LocalGroupMember -Group "groupname" -Member "username"
  • Remove a user from a group:

    Remove-LocalGroupMember -Group "groupname" -Member "username"
  • Get local group members:

    Get-LocalGroupMember -Group "Administrators"
  • Change user password:

    $SecurePassword = ConvertTo-SecureString "NewPassword" -AsPlainText -Force
    Set-LocalUser -Name "username" -Password $SecurePassword
  • Set user account to expire:

    Set-LocalUser -Name "username" -AccountNeverExpires $false

Security and Permissions

  • Check file permissions:

    Get-Acl -Path "filename"
  • Change file permissions:

    $acl = Get-Acl -Path "filename"
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("username", "FullControl", "Allow")
    $acl.SetAccessRule($rule)
    Set-Acl -Path "filename" -AclObject $acl
  • Check for permissions inheritance:

    (Get-Acl -Path "filename").AreAccessRulesProtected
  • View active network connections:

    Get-NetTCPConnection
  • Stop a process by PID:

    Stop-Process -Id pidnumber
  • Start a process:

    Start-Process -FilePath "processname.exe"

System and Application Logs

  • View Windows Event Logs:

    Get-EventLog -LogName Application
  • Export Event Log to a file:

    Export-Clixml -Path "filename.xml" -InputObject (Get-EventLog -LogName Application)
  • View specific log entries:

    Get-EventLog -LogName Application -EntryType Error | Format-List
  • Clear event log:

    Clear-EventLog -LogName Application
  • Export specific log entries to CSV:

    Get-EventLog -LogName Application -EntryType Error | Export-Csv -Path "errors.csv"

System Maintenance

  • Check system health:

    Get-HealthStatus
  • Repair Windows image:

    Repair-WindowsImage -Online -RestoreHealth
  • Optimize drives:

    Optimize-Volume -DriveLetter C -ReTrim -Verbose
  • Run system file checker:

    sfc /scannow
  • Update Windows Defender:

    MpCmdRun.exe -SignatureUpdate

PowerShell Script Management

  • Run a PowerShell script:

    .\script.ps1
  • Check execution policy:

    Get-ExecutionPolicy
  • Set execution policy:

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  • List all scheduled tasks:

    Get-ScheduledTask
  • Create a new scheduled task:

    $action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File C:\path\to\script.ps1"
    $trigger = New-ScheduledTaskTrigger -Daily -At "2:00AM"
    Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "MyTask"

Summary

This list covers an extensive range of PowerShell commands for system administration, file management, network diagnostics, security, and maintenance tasks. These commands provide robust functionality for managing and securing Windows environments effectively. Copy and paste these commands into your PowerShell console as needed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published