Archive for the ‘Windows Server 2008’ Category

Hyper-v Server R2 Remote management in Workgroup

August 27, 2010

Here I tried to make clear guide how to manage Windows Server 2008 R2 with Hype-V role installed  or Hyper-V server from Windows 7 machine while both Win 7 and Hyper-V server are in workgroup scenario. You can find detailed post here:

What I do in this post is to make some basic guide with steps 1,2 etc.

1. Install Hyper-V Server R2. Nothing strange just as a usual Windows Server 2008 R2

2. Create two identical users on both machines with the same password. For example:

a. On Win 7 machine 

b. On Hyper-V Server issue a command

net user Deen * /add

In my cause I add Deen in local administrators group on both machines but isn’t necessary to be in local administrators group on the Server.

3. Issue a command in a Hyper-V server again

Netsh advfirewall firewall set rule group=”Windows Management Instrumentation (WMI)” new enable=yes

Net localgroup “Distributed COM Users” /add  HV-Server\Deen

(HV-Server is the name of HyperV Server machine)

4. Right click on the computer management console (top) and select connect to another computer.

Then connect to Hyper-V Server

You have to set two times the security. Once for Root\CIMV2 and then for the ROOT\virtualization.

For CIMv2 only the permission Enable Account is sufficient.

For \Root Virtualization enable account and remote enable is enough.

You can add the requested permissions in the whole root three but is less secure.

5. Work with AZman on Hyper-V Server.

Net use * \\HV-Server\c$

After that you have to load one xml file from the server.

Navigate to mapped drive  \ProgramData\Microsoft\Windows\Hyper-V directory on the Hyper-V server and add Deen to Role Assignments Administrator container.

6. Give the following permissions on the Win 7 machine.


Install Windows Server 2008as backup feature on Server Core

March 19, 2010

What do you need to backup Server 2008 Core computer ? Yes there is a feature which makes VSS backups.

start /w ocsetup WindowsServerBackup – this installs windows server backup feature.

After that you can start backing up using cmd tool called wbadmin. Here is one example backing up D: to shared

network folder:

wbadmin start backup -backuptarget:\\Server02\BackupShare  -include:d:

Vbscript creating many folders

March 9, 2010

Very good vbscript if you need to create folders. In my cause i had to create for example in Archive folder many little subfolders from 001,002,..010,011…099,100 to 300.

ParentFolder = “C:\Archive”
set objShell = CreateObject(“Shell.Application”)
set objFolder = objShell.NameSpace(ParentFolder)
FOR i=1 to 9
objFolder.NewFolder “00”+CStr(i)
FOR i=10 to 99
objFolder.NewFolder “0”+CStr(i)
FOR i=100 to 300
objFolder.NewFolder CStr(i)

How to remove files from folder with VBScript

March 9, 2010

Here is the script. It is usefull for example if you need to remove old backup files from a folder or some old log files. The only thing is to put it to task schedule. Here is the script:

Dim Fso

Dim Directory

Dim Modified

Dim Files

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Directory = Fso.GetFolder(“C:\inetpub\logs\logfiles\W3SVC3”)

Set Files = Directory.Files

For Each Modified in Files

If DateDiff(“D”, Modified.DateLastModified, Now) > 30 Then Modified.Delete


So some explanations

Set Fso = CreateObject(“Scripting.FileSystemObject”) //create file system objct

Set Directory = Fso.GetFolder(“some path”) //this is the actual folder which will be searched for files

For Each Modified in Files //this is the actual loop for every file in the directory

If DateDiff(“D”, Modified.DateLastModified, Now) > 30 Then Modified.Delete //here you should set how log the files will be keeped. 30 in this example means if  the files is more than 30 days old then delete it. The funktion compares every file with today date and in this cause if today is 30 days more than date of some file it deletes it.

After that make a simple task schedule with cscript <some filename.vbs>. This will run script in command line.

Here there is some slightly different modification of the script. If somebody wonders how the script could be modified in that manner, that it can remove old files (or data) from subfolder beneath some root folder. Here is the modified script.

Let’s say we have the followind scenario. We have Microsoft SQL server 2008 and a maintenance plan which takes care of backups. All backups have been made in a folder called D:\SQL Backups.

In addition to the above script i will introduce a variable  Dim Subdirectory. In that cause we have Directory and Subdirectory variables. The difference is the line Set SubDirectory = Directory.Subfolders. Whith that line Subdirectory variable gets all subdirectories underneath. f1 is some kind of subsidiary variable represent object to access to every file in every subdirectory.

Dim Fso

Dim Directory

Dim Modified

Dim Files

Dim SubDirectory

Dim f1

Set Fso = CreateObject(“Scripting.FileSystemObject”)

Set Directory = Fso.GetFolder(“D:\SQL Backups”)

Set SubDirectory = Directory.Subfolders

For Each f1 in Subdirectory

Set Files = f1.Files

For Each Modified in Files

If DateDiff(“D”, Modified.DateLastModified, Now) > 3 Then Modified.Delete