How to Delete Multiple DHCP Scopes Using PowerShell

You can remove multiple scopes from your DHCP server by using this simple script which uses the Remove-DhcpServerv4Scope PowerShell cmdlet. The script assumes you have scope IDs in a series (I have scope IDs of 10.0.0.0, 11.0.0.0 and 12.0.0.0). Delete Multiple DHCP Scopes Using PowerShell Step 1. Open notepad and copy/paste the following script and save the file ... Read more

How to Send an Email from Gmail Account Using PowerShell

You can send an email from your Gmail account using only a single command in PowerShell. There are several ways to achieve that, however, this tutorial uses the Send-MailMessage cmdlet. Send-MailMessage cmdlet has following commonly used paramters: –Attachments string The full path and filenames to be attached with an email. –Bcc string Email addresses that you would like to ... Read more

How to Downgrade Forest and Domain Functional Levels

Downgrade the Forest Functional Level Step 1. Open PowerShell with elevated privileges. Step 2. Execute the following command, replace the identity with your domain name and the forestmode with the level you want to downgrade to. Set-ADForestMode –Identity “CANITPRO.com” –ForestMode Windows2008Forest In the above example, I have downgraded the forest functional level to Windows Server 2008. ... Read more

Error when Executing a PowerShell Script for the First Time

When you are executing a PowerShell script for the first time you may encounter the following error: .... cannot be loaded because running scripts is disabled on this system. Why did this happen: PowerShell Execution Policies PowerShell has four execution policies for executing the script. Those four policies are described below: Restricted This is a default policy. ... Read more

How to Fix WinRm Firewall Exception Rule When Enabling PS Remoting

When you are enabling PowerShell remoting using the command Enable-PSRemoting, you may get the following error because your system is connected to the network trough a Wi-Fi connection. PS C:\WINDOWS\system32> winrm quickconfig The following changes must be made: Start the WinRM service. Set the WinRM service type to delayed auto start. Make these changes [y/n]? y ... Read more

How to Set Up an Active Directory on Windows Server 2016 Using PowerShell

In this tutorial, I will explain how to install an active directory on Windows Core Server 2016 using a few PowerShell commands. If you have already configured an AD Domain Service before, you may be aware that there are the following two high-level steps: Installing Active Domain itself. Promoting the server as domain controller. Install ... Read more

How to Check if a User or Group Exists in AD using PowerShell

If you want to check the existence of any user or group in Windows Active Directory, use the following PowerShell script. PowerShell: Check if AD User or Group Exists Step 1. Open PowerShell with elevated privileges. Step 2. Execute the following script: $userobj = Get-ADUser -LDAPFilter "(SAMAccountName=$username)" $vlanobj = Get-ADGroup -LDAPFilter "(SAMAccountName=$vlangroupname)" if ($userobj -eq ... Read more

How to Prompt a User for Input using PowerShell

You can use the read-host command-let to get an input from a user during program execution. PowerShell Input Example Here is a related example, the program gets two numbers in string format and converts them into integers and then sums up those numbers and finally displays the result. The -prompt parameter is used to display a ... Read more