PowerShell is a command shell and full-featured object-oriented scripting language based on .NET. that can be used to manage computers and create scripts to automate various administrative tasks. The PowerShell environment is pre-installed on Windows by default.
You can run PowerShell commands (called cmdlets) from the powershell.exe command line (or pwsh.exe if you are using PowerShell Core 6.x, 7.x), or use the built-in Windows PowerShell ISE script editor (with code highlighting, command reference, and debugging tools). The free Visual Studio Code (VSCode) editor gives you more power over PowerShell code. A history of the commands that you have previously run is available in the PowerShell console.
There are currently two branches of PowerShell:
- Windows PowerShell up to version 5.1 – classic .NET Framework-based version of PowerShell built into Windows. Microsoft has decided to stop developing the PowerShell 5.1 platform.
- PowerShell Core 6.x, 7.x — the latest cross-platform version of PowerShell based on .NET Core. PowerShell Core In active development. You must install and update this version of PowerShell separately. It is possible to install PowerShell Core on a Linux operating system.
With PowerShell, system administrators can automate and manage various components of the desktop versions of Windows, Windows Server roles, and other components of the Microsoft infrastructure, and third-party products.
Windows Server roles and features administration with PowerShell
PowerShell is an excellent tool for the automation of configuration and management of the Windows server platform. Almost anything that you can do with the graphical Windows Server snap-ins can be done with PowerShell. Managing dozens or hundreds of Windows Server 2022/2019/2016/2012R2 hosts simultaneously is made much easier with PowerShell.
- Using PowerShell to install and remove roles in Windows Server;
- SMB File Server: manage shared network folders with PowerShell;
- Install, configure, and manage the Remote Desktop Services (RDS) role: deploying an RDS server farm; setting up the RD Gateway; move RDS roles to another host;
- Enable Wi-Fi support on Windows Server;
- How to install and configure the SNMP service in Windows;
- Basic commands for configuring Windows Server Core from the PowerShell console;
- In order to manage the Hyper-V role, the Hyper-V PowerShell module must be installed. It allows: install Windows in a Hyper-V virtual machine; configure VM autostart; clone, export, and import virtual machines in Hyper-V;
- Using iSCSI disks in Windows Server;
- Install and configure the DHCP server role in Windows Server.
PowerShell cmdlets and scripts for Windows 10 and 11 desktop computers
On user workstations running desktop operating systems (Windows 10 and 11), you can use PowerShell to configure various settings:
- Network settings in Windows: set the IP address and other network parameters using PowerShell; reset Windows network settings; view saved Wi-Fi network passwords;
- Windows Defender Firewall: enable/disable firewall; create, change, or delete firewall rule;
- Using the PSWindowsUpdate PowerShell module to install and manage Windows updates;
- Local Windows user management with PowerShell
- Manage printers: create a printer and install driver with PowerShell; remove printer on Windows; view printer logs;
- Managing disks and partitions with PowerShell; expanding partitions in Windows;
- How to install language packs on Windows
- How to completely uninstall a driver in Windows
- Working with Event Viewer and logs: check Windows event logs with PowerShell; audit user logon events in Windows; enable process tracking audit on Windows; view RDP connection logs; clear event logs in Windows;
- How to install apps using Winget and how to uninstall programs on Windows with PowerShell;
- Microsoft Defender: managing built-in antivirus using PowerShell; how to completely disable Defender on Windows;
- Managing Windows VPN connection using PowerShell
- How to install WSL 2 on Windows; how to move the WSL VHDX file to a different hard disk;
- Install new fonts with PowerShell, restore the default font files and settings in Windows;
- Manage Windows services from the PowerShell console
- How to use PowerShell to get and change computer BIOS/UEFI settings
- Manage NTFS permissions on file system objects with PowerShell
- Use a PowerShell script to send an email from Outlook
- Create, delete, and modify registry values from PowerShell
- Check Windows activation status
- How to integrate security updates and drivers into your Windows install image
Active Directory administration with PowerShell
The RSAT-AD PowerShell module is used to manage an Active Directory forest/domain and objects:
- AD domain controllers: adding additional DC to AD (how to install DC on Windows Server Core); removing (demoting) domain controller; checking the health of domain controllers and replication;
New-ADUser
– create a user in Active Directory;Get-ADUser
– get information about AD domain users;Set-ADUser
– change user properties in AD;Set-ADAccountPassword
– change/reset domain user password;New-ADOrganizationalUnit
– create Organizational Unit (OU) in AD;Unlock-ADAccount
– unlock Active Directory user;Get-ADComputer
– getting computer objects info from Active Directory;Set-ADComputer
– change computer properties in Active Directory;Search-ADAccount
– search for inactive users and computers in AD;Restore-ADObject
—restore deleted AD objects with PowerShell and AD Recycle Bin;- Using PowerShell to manage Active Directory groups;
- Find out from which computer the user account is locked on the domain;
- How to check user logon history in the AD domain;
- List local administrators on all domain computers;
- List the versions and builds of Windows computers in the Active Directory;
- How to reset domain admin password;
- Managing Active Directory GPOs with the PowerShell GroupPolicy module.
Working with files and folders in PowerShell
- Using Import-CSV and Export-CSV cmdlets to read and write data to CSV files from PowerShell scripts
- Reading and writing Excel files with PowerShell
PowerShell for Exchange administrators
PowerShell cmdlets are an important tool for administration and automating on-premises Exchange Server and Exchange Online (Microsoft 365). To connect to Exchange Online, you need to install the EXO module. You can remotely connect to an on-premises Exchange Server host from any computer and import Exchange PowerShell cmdlets into your session.
- How to put Exchange Server into maintenance mode; cleanup, truncate, or move Exchange logs;
- Configuring user mailboxes: enable/disable email forwarding in an Exchange user’s mailbox; grant permissions to access another user’s mailbox or calendar; configure regional settings for Exchange mailbox; manage mailbox Inbox rules; search for and delete e-mail items in all Exchange mailboxes; shared mailboxes automapping in Outlook; setup automatic replies (out-of-Office) in Exchange mailbox;
- Exchange Server: how to check mailbox size and set quotas;
- How to convert a user’s mailbox to a shared mailbox and vice versa;
- Managing Exchange distribution groups;
- How to delete or rename default mailbox database in Exchange;
- Audit user activity in the Exchange mailbox;
- Parsing message tracking logs in the Exchange Server.
PowerShell administration for Microsoft Teams
- Installing Microsoft Teams PowerShell module
- Send a message to the Teams channel with PowerShell
- Export an entire Teams chat history with PowerShell script
- Disable Microsoft Teams auto startup
Manage Microsoft 365 with PowerShell
- How to connect Entra ID (Azure AD) tenant with PowerShell
- Using certificate-based authentication in Microsoft 365 and Exchange Online in PowerShell scripts
- Assign Microsoft 365 licenses to user accounts using PowerShell
- Manage Microsoft 365 groups (Entra AD ex. Azure AD) with PowerShell
- How to restore a Microsoft 365 user after deletion
- Send an email with Microsoft Graph API and PowerShell
PowerShellremoteconnections
- PowerShell remote connection via SSH
- PowerShell Remoting (WinRM) over HTTPS
- Using PowerShell Remoting on non-domain (workgroup) computers
- How to use Enter-PSSession to run interactive PowerShell commands on a remote computer
- How to find the logged username on a remote computer
- Using PowerShell Invoke-Command to run a script on a remote computer
- Check for open ports on a remote host with PowerShell
- Use PowerShell Invoke-WebRequest to retrieve Web page content
- Send emails from PowerShell scripts using
Send-MailMessage
Managing VMware products with PowerShell
- Installing the VMware PowerCLI module
- How to enable and disable SSH on VMware ESXi host
- Create a VMware virtual machine with PowerShell
- Increasing VMware virtual machine disk size
- Enable clipboard copy and paste on VMware ESXi VM
- Adding custom drivers to ESXi image
- Consolidating VM disks in VMware VMware VM disk consolidation
Using PowerShell automation in third-party products
- Collecting data from a PowerShell script in Zabbix
- Send a message to Telegram from PowerShell