Difference between revisions of "Variables (PowerShell)"

Jump to navigation Jump to search
Page deperciated
(→‎Datetime: Turned into subsection of "Object Types" (new heading) and added "IP Address")
(Page deperciated)
 
(3 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 453: Line 456:


=== IP Address ===
=== IP Address ===
The object structure: http://msdn.microsoft.com/en-us/library/system.net.ipaddress
To create an IP address object...
To create an IP address object...
<source lang="powershell">
<source lang="powershell">
Line 460: 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