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 Prevent Users from Shutting Down the Domain Joined Client Computers

Domain users are by default allowed to shutdown, restart, or put the domain-joined client computers to sleep. However, you can use a group policy to prevent them from shutting down or restarting the client computers. Following are step by step instructions written for this purpose. Prevent Users from Shutting Down their Computer Step 1. Open Group ... 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

How to Generate Random Numbers Using PowerShell

When you have to generate random passwords for users, you can execute the get-random command let on PowerShell to create it. Generate Random Number get-random -maximum 2000 -minimum 100 This command, when executed on PowerShell, creates a number between 1999 (not 2000 and always set one number higher in maximum) and 100.

How to Keep Installed Drivers After Running SYSPREP

Sometime it is necessary to keep installed drivers on windows even after running sysprep. You can do so by following these steps. Step-by-Step instructions Step 1: Open run command. Type regedit and then press enter key. Step 2: Go to the following path: GoHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\Sysprep\Settingregedits\sppnp Step 3: Locate PersistAllDeviceInstalls on right side of window. Step 4: Right-click and ... Read more