PowerShell can streamline various system administration tasks on Windows. This guide provides useful scripts and commands to help you manage your system more effectively.
PowerShell allows you to automate user account creation and management. Use the following script to create a new local user account:
New-LocalUser -Name "UserName" -Password (ConvertTo-SecureString "Password" -AsPlainText -Force) -FullName "Full Name" -Description "User account description"
This command creates a new local user with the specified username, password, full name, and description.
Control and monitor Windows services using PowerShell. Here are some common commands:
Get-Service -Name "ServiceName"
Use this command to get the status of a specific service.
Start-Service -Name "ServiceName"
This command starts a specified service.
Stop-Service -Name "ServiceName"
Use this command to stop a running service.
Manage disks and partitions with PowerShell commands. Here are some useful scripts:
Get-Volume
This command retrieves a list of all volumes on your system.
Resize-Partition -DriveLetter C -Size 50GB
Use this command to resize the partition on the C: drive to 50GB.
Retrieve various system information using PowerShell:
Get-ComputerInfo
This command provides detailed information about the computer system.
Get-EventLog -LogName System -Newest 10
This command retrieves the 10 most recent entries from the System event log.