How to Read a Text File Using PowerShell

You can read a text file and display its content using get-content cmdlet in PowerShell. Read textfile example Execute the following command on PowerShell with elevated privileges. Get-Content c:\scripts\test.txt This command will display the contents of the file test.txt which is located in c:\scripts\

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 Create a Function in PowerShell

If you have worked with other programming languages, you have may used functions for code reusability. You can also create functions in PowerShell. PowerShell function example Below is syntax of simple function function hello-world { write-host "hello world"  } You can also pass parameters in a function using param keyword function Get-TimesResult { Param ([int]$a,[int]$b) $c = $a * $b Write-Output ... Read more

PowerShell script for toggling network configuration between dynamic and static on Windows 7

Changing network configuration can be a real pain if you use your computer, a notebook for example, in more than one different network where you need a static configuration instead of a dynamic. Although Windows offers one alternate configuration it is quite circumstantial to access. The following PowerShell script will change network configurations with only ... Read more

Windows Powershell – “Running scripts is disabled on this system”

Powershell scripts can be run on any Windows system as long as they are run from the ISE by pushing the green play button. As soon as you want to run it from the cmd or the desktop file you'll get this error: script1.ps1 cannot be loaded because running scripts is disabled on this system. ... Read more