Set-Variable

Set-Variable allows you to change the value and certain aspects of the created variable. For example, this sets the value of an existing variable:

$objectCount = 23 
Set-Variable objectCount -Value 42 

It is not common to see Set-Variable being used in this manner; it is simpler to directly assign the new value as was done when the variable was created. As with New-Variable, much of Set-Variable's utility comes from the additional parameters it offers, as shown in the following examples.

Setting a description for a variable:

Set-Variable objectCount -Description 'The number of objects in the queue' 

Making a variable private:

Set-Variable objectCount -Option Private 
Private scope:
Private scope is accessible using $private:objectCount. Set-Variable may be used but is not required.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset