Forked from anonymous/gist:57629051557ab4edcafbf43d4823e172
Last active
July 18, 2017 19:32
-
-
Save Szeraax/12cfc16706618d8a74f72f8e47bdaacd 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("") | |
} | |
[string] GetIPAddress() | |
{ | |
$IpList = (Get-NetIPAddress).IPv4Address | |
$loopback = "127*" | |
foreach($ip in $IpList) | |
{ | |
if($ip -like $loopback) | |
{ | |
Return "$ip - true" | |
} | |
} | |
return 0 | |
} | |
} | |
$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