Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Szeraax/12cfc16706618d8a74f72f8e47bdaacd to your computer and use it in GitHub Desktop.
Save Szeraax/12cfc16706618d8a74f72f8e47bdaacd to your computer and use it in GitHub Desktop.
powershell
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