Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

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
  • PowerShellWindows 10Windows 11

    How to Connect VPN Before Windows Logon

    November 14, 2023

    By default, the built-in Windows VPN client does not allow you to connect to the VPN server until the user logs in. This is inconvenient for Active Directory-joined computers connected…

  • AzureExchangeMicrosoft 365PowerShell

    Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023

    To send e-mail through an SMTP server from PowerShell scripts, you can use the built-in Send-MailMessage cmdlet. Its major drawback is that it can only use Basic SMTP authentication and…

  • PowerShellWindows 10Windows Server 2019

    Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023

    In this article, we will look at configuring the Zabbix Agent to retrieve monitoring data from PowerShell scripts. Let’s look at two PowerShell scripts to get some data into Zabbix.…

  • PowerShellWindows 10Windows Server 2019Windows Server 2022

    Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023

    In Windows, you can track printer usage with the Event Viewer. All print jobs sent to the print spooler are logged in the Event Viewer. If you have a print…

  • AzureExchangeMicrosoft 365PowerShell

    PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 6, 2023

    Microsoft Entra ID (ex Azure AD) supports Certificate Based Authentication (CBA). This means that you can use certificate authentication to automatically run your PowerShell scripts with no password entry and…

  • PowerShellTeams

    How to Query and Change Teams User Presence Status with PowerShell

    October 6, 2023

    It may be necessary to check the user’s presence status (Online/Away/Busy) in Microsoft Teams before performing a particular action for some integration scripts. Let’s have a look at how to…

  • PowerShellWindows 10Windows 11

    Installing Language Pack in Windows 10/11 with PowerShell

    September 20, 2023

    In modern versions of Windows 11 22H2 and Windows 10 21H2+, you can use PowerShell to install and manage language packs and language interface language packs (LIPs). In previous builds…

  • ExchangeMicrosoft 365OutlookPowerShell

    Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    October 5, 2023

    In Exchange Server and Exchange Online (Microsoft 365), you can enable email forwarding at the mailbox level (configured by the administrator using the ForwardingAddress attribute), through mailbox Inbox rules, or…

  • PowerShellWindows 10Windows 11Windows Server 2019

    How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

    You can use PowerShell to view or change BIOS/UEFI settings on a Windows computer. In this article, we will look at how to use Windows PowerShell to get or change…

  • PowerShellWindows 10Windows 11Windows 7Windows Server 2019

    How to Create UEFI Bootable USB Drive to Install Windows

    September 13, 2023

    This is a step-by-step tutorial for creating a bootable USB flash drive for a UEFI computer with Windows 10/11, Windows Server 2022/2019/2016, or Windows 7 installation images.

  • 1
  • 2
  • 3
  • …
  • 30

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

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Configuring Port Forwarding in Windows
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Adding Drivers into VMWare ESXi Installation Image
Footer Logo

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


Back To Top