Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Domain name from FQDN with powershell

Tags:

powershell

I had been looking for a short code to do this for a while and finally figured it out myself. Thought I would share it.

$FQDN = "madeup.name.domain.co.in"

I would need the result as name.domain.co.in

like image 609
Rohin Sidharth Avatar asked Dec 07 '25 08:12

Rohin Sidharth


1 Answers

An arguably cleaner solution would be

$FQDN.Substring($FQDN.IndexOf(".") + 1)

This gets the substring of $FQDN starting after the first ..

like image 146
Ben Pschierl Avatar answered Dec 08 '25 21:12

Ben Pschierl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!