Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 1.0 » Set-Variable

Set-Variable - Powershell 1.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

Set-Variable

Description
Set a variable and a value

Usage


Options


Example(s)
Set the value of the "SS64" variable to "My Sample text ":

PS C:\>set-variable -name SS64 -value "My Sample text"

Create a global, read-only variable that contains all processes on the system:

PS C:\>set-variable -name myprocs -value (Get-Process) -option constant -scope global

In the example above, the value is enclosed in parentheses this executes the command: (Get-Process) before storing the result in the variable, rather than just storing the text "Get-Process".