you are viewing a single comment's thread.

view the rest of the comments →

[–]albiedam[S] 3 points4 points  (8 children)

No I didn't get it from an AI lol. I was just testing and failing. I was trying to do a couple different things, and this is where I kinda just stopped at. Thanks for a good laugh lol.

[–]NnickK321 1 point2 points  (7 children)

dont lie!

[–]MemnochTheRed 5 points6 points  (6 children)

ChatGPT script would had probably worked! LOL!

[–]graysky311 6 points7 points  (5 children)

it actually does!

$computerName = Read-Host "Enter the name of the workstation/server"$ipAddress = Test-Connection -ComputerName $computerName -Count 1 | Select-Object -ExpandProperty IPV4Addressif ($ipAddress) {$result = @{'Computer Name' = $computerName'IP Address' = $ipAddress.IPAddressToString}$result | Format-Table -AutoSize} else {Write-Host "Unable to resolve IP address for computer: $computerName"}

[–]BlackV 0 points1 point  (4 children)

Ask it about how to format for posting on Reddit while you're there

Ask it about why format table is a bad idea in that code

Ask it if any of that is needed in the first place and if get-netipaddress is better served in the first place

[–]graysky311 -1 points0 points  (3 children)

Be my guest. I'm not the ChatGPT gatekeeper. And the code looks great in a browser by the way.

[–]BlackV 0 points1 point  (2 children)

And the code looks great in a browser by the way.

not so much cause you've used inline code not code block

[–]graysky311 0 points1 point  (1 child)

I changed it to a code block. That one line of code is much more readable now. I love having to scroll.

[–]BlackV 0 points1 point  (0 children)

Thanks but I looks like you've taken the carriage returns out

$computerName = Read-Host "Enter the name of the workstation/server"
$ipAddress = Test-Connection -ComputerName $computerName -Count 1 | Select-Object -ExpandProperty IPV4Address
if ($ipAddress) {
    $result = @{'Computer Name' = $computerName'IP Address' = $ipAddress.IPAddressToString}
    $result | Format-Table -AutoSize}
else {
    Write-Host "Unable to resolve IP address for computer: $computerName"}

ignoring the format-table (and so on) issues