Difference between revisions of "Variables (PowerShell)"

Jump to navigation Jump to search
Page deperciated
m (→‎IP Address: Added link to MS page)
(Page deperciated)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Depreciated|category=Variables_(PowerShell)}}
  __TOC__
  __TOC__


Line 307: Line 309:
== Arrays ==
== Arrays ==
<source lang="powershell">
<source lang="powershell">
$array = @()           # Create blank array
$array = @()                 # Create blank array
$array += 34           # Add value to end of array
$array = @("one", "two", 3)  # Create an array with some values
$array += 34                 # Add value to end of array
</source>
</source>


Line 462: Line 465:
To confirm a supplied address is valid...
To confirm a supplied address is valid...
<source lang="powershell">
<source lang="powershell">
if ([System.Net.IPAddress]::TryParse($IP-to-test) {
if ( [System.Net.IPAddress]::TryParse($IP2test) ) {
     Write-Host "$IP-to-test is a valid address"
     Write-Host "$IP2test is a valid address"
}
}
</source>
</source>

Navigation menu