Skip to main content

Scripts to Manage Computers

About 35 minPowershellScripts to Manage Computerspowershellpwshwindowsscriptuseful-script

Scripts to Manage Computers 관련


add-firewall-rules.ps1

add-firewall-rules.ps1

Adds firewall rules for executables, needs admin rights.

This PowerShell script adds firewall rules for the given executable. Administrator rights are required.

Parameters
PS> ./add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>]

-PathToExecutables <String>
    Specifies the path to the executables
    
    Required?                    false
    Position?                    1
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-cpu.ps1

check-cpu.ps1

Checks the CPU temperature

Checks the CPU temperature

Parameters
[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-dns.ps1

check-cpu.ps1

Checks the CPU temperature

This PowerShell script measures and prints the DNS resolution speed by using 200 popular domains.

Parameters
PS> ./check-dns.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-drive-space.ps1

check-drive-space.ps1

Checks a drive for free space left.

This PowerShell script checks a drive for free space left (20 GB by default).

Parameters
PS> ./check-drive-space.ps1 [[-Drive] <String>] [[-MinLevel] <Int32>] [<CommonParameters>]

-Drive <String>
    Specifies the drive to check
    
    Required?                    false
    Position?                    1
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-MinLevel <Int32>
    Specifies the minimum level in Gigabyte
    
    Required?                    false
    Position?                    2
    Default value                20
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-file-system.ps1

check-file-system.ps1

Checks the file system of a drive (needs admin rights).

This PowerShell script checks the file system of a drive. It needs admin rights.

Parameters
PS> ./check-file-system.ps1 [[-Drive] <String>] [<CommonParameters>]

-Drive <String>
    Specifies the drive to check
    
    Required?                    false
    Position?                    1
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-health.ps1

check-health.ps1

Checks the system health.

This PowerShell script queries the system health of the local computer (hardware, software, and network) and prints it.

Parameters
PS> ./check-health.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-ping.ps1

check-ping.ps1

Checks the ping latency to the internet.

This PowerShell script measures the ping roundtrip times from the local computer to 10 Internet servers.

Parameters
PS> ./check-ping.ps1 [[-hosts] <String>] [<CommonParameters>]

-hosts <String>
    Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,github.com,google.com,live.com,twitter.com,youtube.com)
    
    Required?                    false
    Position?                    1
    Default value                amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,github.com,google.com,live.com,twitter.com,youtube.com
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-swap-space.ps1

check-swap-space.ps1

Checks the swap space for free space left.

This PowerShell script queries the status of the swap space and prints it.

Parameters
PS> ./check-swap-space.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]

-MinLevel <Int32>
    Specifies the minimum level (10 GB by default)
    
    Required?                    false
    Position?                    1
    Default value                10
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

check-windows-system-files.ps1

check-windows-system-files.ps1

Checks the validity of the Windows system files (needs admin rights).

This PowerShell script checks the validity of the Windows system files. It requires admin rights.

Parameters
PS> ./check-windows-system-files.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

enable-crash-dumps.ps1

enable-crash-dumps.ps1

Enables the writing of crash dumps.

This PowerShell script enables the writing of crash dumps.

Parameters
PS> ./enable-crash-dumps.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

hibernate.ps1

hibernate.ps1

Hibernates the local computer immediately.

This PowerShell script hibernates the local computer immediately.

Parameters
PS> ./hibernate.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

install-github-cli.ps1

install-github-cli.ps1

Installs GitHub CLI.
Parameters
PS> ./install-github-cli.ps1 [<CommonParameters>]
[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

install-chrome-browser.ps1

install-chrome-browser.ps1

Installs the Google Chrome browser

This PowerShell script installs the latest Google Chrome Web browser.

Parameters
PS> ./install-chrome-browser.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

install-knot-resolver.ps1

install-knot-resolver.ps1

Installs the Knot Resolver (needs admin rights).

This PowerShell script installs Knot Resolver. Knot Resolver is a DNS resolver daemon. It needs admin rights.

Parameters
PS> ./install-knot-resolver.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

install-ssh-client.ps1

install-ssh-client.ps1

Installs a SSH client (needs admin rights).

This PowerShell script installs a SSH client (needs admin rights).

Parameters
PS> ./install-ssh-client.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

install-ssh-server.ps1

install-ssh-server.ps1

Installs a SSH server (needs admin rights).

This PowerShell script installs a SSH server (needs admin rights).

Parameters
PS> ./install-ssh-server.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

install-signal-cli.ps1

install-signal-cli.ps1

Installs signal-cli from github.com/AsamK/signal-cli.

This PowerShell script installs signal-cli from AsamK/signal-cliopen in new window.

See the Web page for the correct version number.

Parameters
PS> ./install-signal-cli.ps1 [[-Version] <String>] [<CommonParameters>]

-Version <String>
    Specifies the version to install
    
    Required?                    false
    Position?                    1
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

install-updates.ps1

install-updates.ps1

Installs updates (need admin rights).

This PowerShell script installs software updates for the local machine (needs admin rights). Use the script 'list-updates.powershell' to list available updates.

@tab:active Parameters

PS> ./install-updates.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

@tab Example

PS> ./install-updates.ps1
# 

@tab Script Content

<#
.SYNOPSIS
	Installs updates
.DESCRIPTION
	This PowerShell script installs software updates for the local machine (needs admin rights).
	Use the script 'list-updates.ps1' to list available updates.
.EXAMPLE
	PS> ./install-updates.ps1
.NOTES
	Author: Markus Fleschutz | License: CC0
#>

try {
	$StopWatch = [system.diagnostics.stopwatch]::startNew()

	if ($IsLinux) {
		"⏳ (1/4) Querying updates for installed Debian packages..."
		& sudo apt update

		"⏳ (2/4) Upgrading installed Debian packages..."
		& sudo apt upgrade --yes

		"⏳ (3/4) Removing obsolete Debian packages..."
		& sudo apt autoremove --yes

		"⏳ (4/4) Upgrading installed Snap packages..."
		& sudo snap refresh
	} else {
		Write-Progress "⏳ Installing updates..."
		" "
		& winget upgrade --all
		Write-Progress -completed " "
	}
	[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
	"✅ installed the updates in $Elapsed sec"
	exit 0 # success
} catch {
	"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
	exit 1
}

:::


install-wsl.ps1

install-wsl.ps1

Installs Windows Subsystem for Linux (WSL), needs admin rights.

This PowerShell script installs Windows Subsystem for Linux. It needs admin rights.

Parameters
PS> ./install-wsl.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-apps.ps1

list-apps.ps1

Lists the installed applications.

This PowerShell script lists the installed apps (from Windows Store or snaps).

Parameters
list-apps.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-cli-tools.ps1

list-cli-tools.ps1

Lists installed command-line interface (CLI) tools.

Lists installed command-line interface (CLI) tools.

Parameters
list-cli-tools.ps1  [<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-dns-servers.ps1

list-dns-servers.ps1

Lists public DNS servers.

Lists public DNS servers.

Parameters
list-dns-servers.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-drives.ps1

list-drives.ps1

Lists all drives.

This PowerShell script lists all local drives as a table.

Parameters
PS> ./list-drives.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-network-shares.ps1

list-network-shares.ps1

Lists all network shares of the local computer.

This PowerShell script lists all network shares of the local computer.

Parameters
PS> ./list-network-shares.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-installed-software.ps1

list-installed-software.ps1

Lists the installed software.

This PowerShell script lists the installed software (except Windows Store apps).

Parameters
PS> ./list-installed-software.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-printers.ps1

list-printers.ps1

Lists all printer known to the computer.

This PowerShell script lists all printers known to the local computer.

Parameters
PS> ./list-printers.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-print-jobs.ps1

list-print-jobs.ps1

Lists all jobs of all printers.

This PowerShell script lists all print jobs of all printer devices.

Parameters
PS> ./list-print-jobs.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-processes.ps1

list-processes.ps1

Lists the local computer processes.

This PowerShell script lists all local computer processes.

Parameters
PS> ./list-processes.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-services.ps1

list-services.ps1

Lists the services on the local computer.

This PowerShell script lists all services installed on the local computer.

Parameters
PS> ./list-services.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-system-info.ps1

list-system-info.ps1

Lists system information on the local computer.

This PowerShell script lists system information of the local computer.

Parameters
PS> ./list-system-info.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-tasks.ps1

list-tasks.ps1

Lists all Windows scheduler tasks.
Parameters
PS> ./list-system-info.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-timezone.ps1

list-timezone.ps1

Lists the current time zone details.

This PowerShell script lists the details of the current time zone.

Parameters
PS> ./list-timezone.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-timezones.ps1

list-timezones.ps1

Lists all time zones available.

This PowerShell script lists all available time zones.

Parameters
PS> ./list-timezones.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

list-user-groups.ps1

list-user-groups.ps1

Lists the user groups on the local computer.

This PowerShell script lists the user groups of the local computer.

Parameters
PS> ./list-user-groups.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

poweroff.ps1

poweroff.ps1

Halts the local computer (needs admin rights).

This script halts the local computer immediately (needs admin rights).

Parameters
PS> ./poweroff.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

query-smart-data.ps1

query-smart-data.ps1

Queries the S.M.A.R.T. data of your HDD/SSD's.

Queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory.

(use smart-data2csv.ps1 to powershell a CSV table for analysis).

Requires smartctl (smartmontools) and admin rights. For automation copy this script to /etc/cron.daily

Parameters
PS> ./query-smart-data.ps1 [[-Directory] <String>] [<CommonParameters>]

-Directory <String>
    Specifies the path to the target directory
    
    Required?                    false
    Position?                    1
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

reboot.ps1

reboot.ps1

Reboots the local computer (needs admin rights).

This PowerShell script reboots the local computer immediately (needs admin rights).

Parameters
PS> ./reboot.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

remove-print-jobs.ps1

remove-print-jobs.ps1

Removes all jobs from all printers.

This PowerShell script removes all print jobs from all printer devices.

Parameters
PS> ./remove-print-jobs.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

restart-network-adapters.ps1

restart-network-adapters.ps1

Restarts all local network adapters.

This PowerShell script restarts all local network adapters (needs admin rights).

Parameters
PS> ./restart-network-adapters.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

upgrade-ubuntu.ps1

upgrade-ubuntu.ps1

Upgrades Ubuntu Linux to the latest (LTS) release.

This PowerShell script upgrades Ubuntu Linux to the latest (LTS) release.

Parameters
PS> ./upgrade-ubuntu.ps1 [<CommonParameters>]

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

wakeup.ps1

wakeup.ps1

Wakes up a computer using Wake-on-LAN.

This PowerShell script sends a magic UDP packet twice to a computer to wake him up (requires Wake-On-LAN).

Parameters
PS> ./wakeup.ps1 [[-MACaddress] <String>] [[-IPaddress] <String>] [[-Port] <Int32>] [<CommonParameters>]

-MACaddress <String>
    Specifies the host's MAC address (e.g. 11:22:33:44:55:66)
    
    Required?                    false
    Position?                    1
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-IPaddress <String>
    Specifies the host's IP address or subnet address (e.g. 255.255.255.255)
    
    Required?                    false
    Position?                    2
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Port <Int32>
    Specifies the UDP port (9 by default)
    
    Required?                    false
    Position?                    3
    Default value                9
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.

이찬희 (MarkiiimarK)
Never Stop Learning.