# Adding DNS Alias | Replacing File Server

[https://www.edwardsd.co.uk/work/2020/04/adding-dns-alias-replacing-file-server/](https://www.edwardsd.co.uk/work/2020/04/adding-dns-alias-replacing-file-server/)

[https://support.microsoft.com/en-gb/help/3181029/smb-file-server-share-access-is-unsuccessful-through-dns-cname-alias](https://support.microsoft.com/en-gb/help/3181029/smb-file-server-share-access-is-unsuccessful-through-dns-cname-alias)

[https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc835082(v=ws.10)](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc835082(v=ws.10))

When replacing a file server with new server and new name you probably want to keep the old name and add a redirect. Originally, I thought this was a simple “change the DNS IP” and job done but there’s a little bit more to it than just that!

**1) Locate OLDSERVER entry in DNS and delete it.**

**2) If the OLDSERVER server AD object still exists, you need to delete it. Failing to remove the old computer object will result in this error:**

*Unable to add NEWSERVER.*  
*as an alternate name for the computer.*  
*The error is: Cannot create a file when that file already exists.*  
*The command failed to complete successfully.*

**3) Run this command to add the server alias:**

<div id="bkmrk-netdom-computername-"><div class="syntaxhighlighter nogutter  powershell" id="bkmrk-netdom-computername--1"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2">`netdom computername NEWSERVER /add:OLDSERVER`</div></div></td></tr></tbody></table>

</div></div>**Note:** if you have subdomains in use (sub.domain.com) then you need to specifically define this overwise the object will add “oldserver.domain.com” rather than “oldserver.sub.domain.com”

**4) Register the machine in DNS**

<div id="bkmrk-ipconfig-%2Fregisterdn"><div class="syntaxhighlighter nogutter  powershell" id="bkmrk-ipconfig-%2Fregisterdn-1"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2">`IPConfig /RegisterDNS`</div></div></td></tr></tbody></table>

</div></div>**5) Run this command to check the aliases are shown on the machine**

<div id="bkmrk-netdom-computername--2"><div class="syntaxhighlighter nogutter  powershell" id="bkmrk-netdom-computername--3"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2">`netdom computername NEWSERVER /enum`</div></div></td></tr></tbody></table>

</div></div>**6) Final check to show what SPF entries have been created:**

<div id="bkmrk-setspn--l-newserver"><div class="syntaxhighlighter nogutter  powershell" id="bkmrk-setspn--l-newserver-1"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2">`setspn` `-l` `NEWSERVER`</div></div></td></tr></tbody></table>

</div></div>