How to Append Data to a Text File Using PowerShell

You can use the PowerShell add-content cmdlet to append data to a text file. Here are an example and the command-line options that you can use. Powershell add-content example Step 1. Open PowerShell with elevated privileges Step 2. Execute the following command, (change the file path) Add-Content c:\scripts\test.txt "The End" By default, the data is appended after ... Read more

How to save command output to a file using PowerShell

PowerShell command to file

PowerShell is a command-line shell designed particularly for system administrators. It helps administrators to manage and automate the administration of Windows operating systems and the Apps running on it. PowerShell has the ability to save the outputs of commands you run in it into a file which you can later view, analyze, and share it ... Read more

How to Change Your IP Address in Windows Using PowerShell

Set IP address with PowerShell

You may know how to change IP address via GUI. It's pretty easy. Just go to Control panel > network and internet, selecting the IPv4 Properties and change the IP address. This whole process will take around a minute to do so. But what if you have to do it on multiple systems and repeat ... 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 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

Use Double-Quotes in Quoted Expressions with ASCII Codes in Windows Powershell

While scripting, you may encouter the problem that you have an expression that uses double-quotes as tags and therefore cannot use any double-quotes inside these tags. You can circumvent this problem by using ASCII codes to add certain keys. This is done by tagging out, joining with ASCII code and joining with the tagged expression ... Read more