Skip to content

Instantly share code, notes, and snippets.

Created July 18, 2017 19:21
Show Gist options
  • Save anonymous/57629051557ab4edcafbf43d4823e172 to your computer and use it in GitHub Desktop.
Save anonymous/57629051557ab4edcafbf43d4823e172 to your computer and use it in GitHub Desktop.
powershell
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