Created
July 18, 2017 19:21
-
-
Save anonymous/57629051557ab4edcafbf43d4823e172 to your computer and use it in GitHub Desktop.
powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Computer{ | |
[string] GetComputerName() | |
{ | |
$raw_name = hostname | |
$name = $raw_name.trim("") | |
return $name.trim("") | |
} | |
[void] GetIPAddress() | |
{ | |
$IpList = ((Get-NetIPAddress).IPv4Address).tostring() | |
$loopback = "127*" | |
foreach($ip in $IpList) | |
{ | |
if($ip -like $loopback) | |
{ | |
Write-Output "true" | |
} | |
else | |
{ | |
Write-Output "False" | |
} | |
} | |
} | |
} | |
$MyComputer = [Computer]::new() | |
$MyComputer.GetComputerName() | |
$Mycomputer.GetIPAddress() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment