Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

Using PowerShell for System Administration and Automation Tasks

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.

powershell automation for system administrators

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
  • PowerShellQuestions and AnswersWindows 11Windows Server 2022

    View Windows Update History with PowerShell (CMD)

    April 29, 2025

    The Windows Update History GUI in the Settings app provides only basic information about installed updates (accessible via the URI shortcut ms-settings:windowsupdate-history) and is not convenient for searching. In this…

  • PowerShellQuestions and AnswersWindows 10Windows 11

    Uninstalling Windows Updates via CMD/PowerShell

    April 18, 2025

    If you’re experiencing problems or errors on a computer after installing Windows updates, you might want to uninstall a specific update or all recently installed updates to help resolve the…

  • PowerShellQuestions and AnswersWindows 10Windows 11Windows Server 2022

    Allowing Ping (ICMP Echo) Responses in Windows Firewall

    April 15, 2025

    By default, the built-in Windows Firewall blocks incoming ICMP Echo Request packets for security reasons on Windows 10/11 desktops and Windows Server hosts. This means you won’t be able to…

  • PowerShellQuestions and AnswersWindows 10Windows 11

    How to Pause (Delay) Update Installation on Windows 11 and 10

    April 11, 2025

    In current Windows 10 and 11 builds, you can delay update installation for up to 35 days (or up to 7 days on Windows Insider builds). This delay period is…

  • PowerShellWindows 11Windows Server 2022

    How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 11, 2025

    Alternatively to using text log files in scripts, you can write event information directly to the Event Viewer logs. In this article, we’ll look at how to write logs to…

  • PowerShellWindows 11Windows Server 2022

    How to Hide (Block) a Specific Windows Update

    March 3, 2025

    Sometimes, after you install a Windows update, you might find that the operating system, a particular program, or a driver stops working or causes conflicts. In this case, you must…

  • PowerShellWindows 10Windows 11

    Maximum Concurrent Connections Limit in Windows 10 and 11

    February 24, 2025

    The number of simultaneous network connections from other computers is limited in the desktop editions of Windows. For example, only 20 simultaneous incoming sessions (connections) are supported on Windows 10…

  • PowerShellQuestions and AnswersWindows 10Windows 11

    Windows: How to Turn Off Monitor with Command Line

    February 17, 2025

    Windows can automatically turn off your monitor when it is not in use. On laptops, turning off the display can have a positive effect on power consumption and battery life.…

  • PowerShellWindows 11Windows Server 2022

    How to Configure Windows Firewall Logging and Analyze Logs

    February 17, 2025

    If you suspect that the built-in Windows Defender firewall is blocking network connections (from a specific program or service), it is a bad idea to disable it completely. Instead, you…

  • PowerShellQuestions and AnswersWindows 10Windows 11

    Get the Computer Uptime (Last Boot Time) on Windows

    January 13, 2025

    There are several ways to find out how long Windows has been running (uptime) since the last boot.

  • 1
  • 2
  • 3
  • …
  • 30
join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Assign (Passthrough) a Physical GPU to a Hyper-V Virtual Machine
  • Run PowerShell Scripts on a Schedule with Task Scheduler
  • Check Windows 11 Hardware Readiness with PowerShell Script
  • Extend an Expired User Password in Active Directory
  • How to Add or Remove Pinned Folders to Quick Access with PowerShell and GPO
  • How to Enable and Configure Wake-on-LAN (WoL) in Windows
  • How to Find Windows Version and Build Number Installed
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top