Welcome to the blog of mechanised.com

This blog is mainly a technical repository of information on Virtualisation tools and management for our hosting service.

Also for HP's Bladesystem that we use at both our datacentres.

Other articles are also included on .Net development and MS SQL Server as well as other interesting things we come across.

Tuesday 13 March 2018

Server core 2016 handy commands

Setting up new server with core (no GUI) handy commands for setting up:

1) Setting static IP (using sconfig) - unbinding components not needed (everything except IPv4)

Listing current bound components:
PS> Get-NetAdapterBinding -InterfaceAlias Ethernet

Disable with the following commands:
PS> Disable-NetAdapterBinding -InterfaceAlias "Ethernet" -ComponentID XXXXX

2) Create extra drives for data/SQL server etc.

Change current CDROM drive letter
DISKPART> list volume
DISKPART> select volume 0
DISKPART> assign letter=F

Create drive for SQL data/log files etc.
Use Get-Disk first to see the drive numbers
Get-Disk -Number 1 | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -UseMaximumSize -DriveLetter D | Format-Volume -FileSystem NTFS -NewFileSystemLabel "DATA" -AllocationUnitSize 65536

Get-Disk -Number 2 | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -UseMaximumSize -DriveLetter E | Format-Volume -FileSystem NTFS -NewFileSystemLabel "LOG" -AllocationUnitSize 65536

If installing SQL Server, this must be done on command line as the GUI doesn't work.

3) When protected by additional firewall, turn off Windows local firewall:
Get-NetFirewallProfile | Set-NetFirewallProfile -enabled false

Check you can access the server remotely for settings you need to change etc. using Server Manager from another machine.

Change the port that SQL Server is listening on, as you can't use SQL Server Configuration Manager, run SQL Powershell from: C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\SQLPS.exe
Then run these commands:
$MachineObject = new-object ('Microsoft.SqlServer.Management.Smo.WMI.ManagedComputer') .
$ProtocolUri = "ManagedComputer[@Name='" + (get-item env:computername).Value + "']/ServerInstance[@Name='SQL2016']/ServerProtocol"
$tcp = $MachineObject.getsmoobject($ProtocolUri + "[@Name='Tcp']")
$MachineObject.getsmoobject($tcp.urn.Value + "/IPAddress[@Name='IPAll']").IPAddressProperties[1].Value = "1437"

Stop and restart the SQL Service and then you can connect with SSMS on a remote machine to the new port:
net stop MSSQL$SQL2016
net start MSSQL$SQL2016

No comments: