Allowing PowerShell executing scripts

By default PowerShell is restricted to not allow script execution. To allow script execution do the following

Open PowerShell in elevated mode (run as administrator) and run the following command:
Set-ExecutionPolicy unrestricted

To verifiy how if script execution is allowed or not run the following command in PoweShell:
Get-ExecutionPolicy

Enable autologon in Windows Server 2008

To make the option “Users must enter a user name and password to use this computer” visible on a domain joined Windows Server 2008 do the following:

1. Run the following comand in cmd:
reg add “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” /v AutoAdminLogon /t REG_SZ /d “1” /f

2. Click start, run. Write: control userpasswords2 and click ok to “open advanced user accounts control panel”.
control userpasswords2

3. Make sure “Users must enter a user name and password to use this computer” is disable. Click ok.

4. Specify username and password to use in autologon.
autologon

Access denied when adding TCP/IP printer port in Windows 2008

You get the following error when adding a printer using a TCP/IP port:

add_printer_access_denied

The problem is that you need to “elevate to administrator privileges” (run as administrator) to add a TCP/IP port. I have’nt found any way to do that when adding a printer. The solutions is to logon as administrator in the console and then add the print and TCP/IP port.

Update:
To add a printer as administrator do the following.
1. Open printers in control panel.
2. Right click in the white area. Choose “Run as administrator”/”Add printer…”.

privileges

Configurate Windows 2008 Server Core

Here are som useful stuff when installing and configurate Windows 2008 Server Core.

Network
Show network interfaces
> netsh interface ipv4 show interfaces

Rename network interface
> netsh interface set interface name = <interface name> newname = <new interface name>

Change static IP-address
> netsh interface ipv4 set adress ”<interface name>” static 192.168.0.1 255.255.25.0 192.168.0.1

Change to DHCP
> netsh interface ipv4 set addresses name=”<interface name>” source=dhcp

Show IP-address
> netsh interface ipv4 show addresses

Add primery DNS server
> netsh interface ipv4 set dnsserver name=”<interface name>” source=static address=<primery dns servers ip-address>

Add secondary DNS server
> netsh interface ipv4 add dnsserver name=”<interface name>” address=<secondary dns servers ip-address>

Enable Remote Administration in firewall
> netsh advfirewall firewall set rule group=”Remote Administration” new enable=yes

Enable Windows Firewall Remote Administration in firewall
> netsh advfirewall firewall set rule group=”Windows Firewall Remote Management” new enable=yes

Disable firewall
> netsh firewall set opmode disable

Enable firewall
> netsh firewall set opmode enable

Show computername
> hostname

Change computername
> netdom renamecomputer <computer name> /newname:<new computer name>

Change name of a domain-joined server
> netdom renamecomputer %computername% /NewName:<new computer name> /userd:<domain\username> /password:*

Join a domain
> netdom join %computername% /domain:<domain> /userd:<username> /passwordd:*

Remove computer from domain
> netdom remove

Enable Remote Desktop. Only support Windows Vista/2008 clients
> Cscript %windir%\system32\SCRegEdit.wsf /ar 0

Enable Remote Desktop. Support Windows XP/2003/Vista/2008 clients
> Cscript %windir%\system32\SCRegEdit.wsf /ar 0
> Cscript %windir%\system32\SCRegEdit.wsf /cs 0

Users, Groups & seciruity
Add a user to the local Administrators group
> net localgroup Administrators /add <domain>\<username>

Remove a user from the local Administrators group
> net localgroup Administrators /delete <domain>\<username>

Change administrator password
> net user administrator *

Show security settings on a folder or file
> cacls <file or folder path>

KMS (
Key Management Service)
Install KMS
> slmgr -ipk <KMS key>

KMS activation
> slmgr -ato

Display KMS license information
> slmgr – dlv

Check for KMS in DNS
> nslookup -type=srv _vlmcs._tcp

Misc
Configure the paging file
>wmic pagefileset where name=”<path/filename>” set InitialSize=<initialsize>,MaximumSize=<maxsize>

Reboot server
> shutdown /r /t 0

Shutdown server
> shutdown /s /t 0

List event logs type
> wevtutil el

List running services
> sc query
> net start

Start a service
sc start <service name> or net start <service name>

Stop a service
> sc stop <service name>

> net stop <service name>

Stop/kill a process
> taskkill /PID <process ID>

Move file
> move “z:\Windows6.0-KB950050-x64.msu” “c:\Windows6.0-KB950050-x64.msu”

Copy file
> copy “z:\Windows6.0-KB950050-x64.msu” “c:\Windows6.0-KB950050-x64.msu”

Roles
Show server roles
> oclist

Install server roles
> ocsetup

example:
> start /w ocsetup Microsoft-Hyper-V

Hyper-V
Install virtual machine integrated components
Mount integrated components cd from action menu.
D:\support\amd64\setup.exe or D:\support\x86\setup.exe

Update Hyper-V
Download and copy Windows6.0-KB950050-x64.msu to your core server.
Example:
Download Windows6.0-KB950050-x64.msu to your fileserver.

From Core server:
> net use z: \\fileserver\share\
> Z:
> copy Windows6.0-KB950050-x64.msu c:\
> C:
> net use z: delete
> Windows6.0-KB950050-x64.msu