Wednesday, August 31, 2011

Changing authentication mode for Sql Server express edition

One way of doing it is through sql server management studio explained over here

http://msdn.microsoft.com/en-us/library/ms188670.aspx

But if you haven’t installed the management studio than in that case you need to make following change in the registry

HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Microsoft SQL server / MSSQL.1/ MSSQLSERVER/ LoginMode

Click on it change it’s value from 1 to 2.

Then Restart your sql server service !!!

After you have done this you need to enable you sa account for sql server authentication for this follow these steps

1) Open SQL Server Management Studio Express and Login
2) In Object Explorer, click Security followed by Logins
3) Right click sa user and select Properties.
4) Uncheck Enforce password policy
5) Select Status. Click the Grant and Enabled radio buttons. Click OK
6) Restart your database server and select restart.

That’s it

Source : http://nishantrana.wordpress.com/2009/01/07/changing-authentication-mode-for-sql-server-express-edtion/

Tuesday, August 30, 2011

PsTools - Executing Program on a remote windows 7 machine.

I could execute the program but it was running in the background. After troubleshooting figured out that you need to put the sessionid to make sure it displays for the user.

psexec -s -d -i 2 \\win7vm -u "ijaved" -p "***"  "calc.exe"

The number 2 above identified my session which was RDP. You can find the sessionid via taskmanager.

WMIC - Usefull Commands



Update static IP address wmic nicconfig where index=9 call enablestatic("192.168.16.4"), ("255.255.255.0")

Change network gateway wmic nicconfig where index=9 call setgateways("192.168.16.4", "192.168.16.5"),(1,2)

Enable DHCP wmic nicconfig where index=9 call enabledhcp

Service Management wmic service where caption="DHCP Client" call changestartmode "Disabled"

Start an application wmic process call create "calc.exe"

Source : http://blogs.technet.com/b/jhoward/archive/2005/02/23/378726.aspx

Thursday, August 25, 2011

Disable IPv6 on Win 7 / Windows Server 2008 via cli (cmd)

Run the following command in cmd and that will do the trick. Make sure you open cmd with "Run As Administrator".

reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 255

Wednesday, August 24, 2011

VirtualBox - Physical to Virtual Machine - P2V

Usually I use Windows System Image Backup on Windows 7 to make a *.vhd of the physical machine and move it to VirtualBox and fire it up. That works fine.

Life is never easy. So I was given a task to migrate Xp Physical machine to VirtualBox. Xp doesn't have Windows System Image option so I was stuck.

I found Disk2Vhd which did the trick. All I had to do is boot the xp machine up and run the software and it created a vhd. Took few hours but end result was awesome.

All I had to on VirtualBox was to create new machine select the existing hard drive and point it to vhd(vhd created by Disk2Vhd) and boot it up.

Gotcha : Only works for Windows OS
Source : http://www.sysprobs.com/virtualbox-p2v-disk2vhd-errors-fix

Update :

Alrite I wanted to share problem i faced when running virtualbox vm(p2v) on optiplex 960. Xp won’t boot and kept on giving me bluescreens.

I ran the same VM on optiplex 780 and it worked fine and booted without a problem. So it was hardware based issue with 960 model.

After wasting 2 hours toggling with options and google i found the solution :-

1- Make sure in VM Settings (System / Processor – The option for Extended Features: Enable PAE/NX) is enabled.

2- From XP Safe Mode (Yes VM boots into Safe Mode) run this command from CLI “sc config intelppm start= disabled”

Tuesday, August 23, 2011

Increase Virtualbox Hard Drive Space

You can increase VirtualBox Version 4+ hard drive size by using command line.

Use the following command from Program Files folder:-

"VBoxManage.exe modifyhd "location of virtual drive.vdi" --resize 25000(new size in mb)

Example :-

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd "C:\VM\Windows 7 x64\Windows 7 x64.vdi" --resize 25000
Result will look like the following :-

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

That should expand the drive size but you have to increase the partition size from the OS.

Note: If you have snapshots then you have to delete them otherwise this won't work. I am trying to figure out if we can do without deleting the snapshots. I got some very clean snapshots which I don't want to lose.
Source : http://www.my-guides.net/en/content/view/122/26/

Monday, August 22, 2011

Enable Remote Desktop via WMIC CLI

Got a call from employee who called in sick and wanted to remote desktop to his machine. He did not enable the "allow remote desktop to this machine" and could not remote desktop to his machine. One of the request was "do not log me out cause I have unsaved document opened".

Had two solution.
  1. Log him off and say tough luck
  2. Reset his password to a default one and login as him/her and enable it. (Good solution if you ask me)
  3. Find a better solution! and I did and WMIC came to the rescue.
Source : http://www.vedivi.com/support/blog/71-how-to-enable-remote-desktop-programmatically.html
I had some experience with WMIC and I knew it probably had something which can do just that and finally found the above post explaing different ways to run WMIC command to enable Remtoe Desktop. I am only interested in enabling remote desktop access to remote pc. So here's the command I have to play around with :-
  • To verify if its enable or disabled use :-
wmic /node:"RemoteServer" /user:"domain\AdminUser" /password:"password"
RDToggle where servername="RemoteServer" get AllowTSConnections

  • To enable Remote Desktop Access
wmic /node:"RemoteServer" /user:"domain\AdminUser" /password:"password"
RDToggle where servername="RemoteServer" call SetAllowTSConnections 1


I used FQDN for 1st RemoteServer and used ComputerName for 2nd RemoteServer.

So before playing with our production server. I fired my test lab which is Win 2008 R2 Sp1 and Client Win 7 Pro.

From the Server I tried :-

C:\Users\Administrator>wmic /node:"testpc.plab.local" /USER:"plab\administrator" RDTOGGLE WHERE ServerName="testpc" CALL SetAllowTSConnections 1
That gives you a prompt to input password for the administrator

Enter the password :********
Executing (\\TESTPC\ROOT\CIMV2\TerminalServices:Win32_TerminalServiceSetting.ServerName="TESTPC")->SetAllowTSConnections()

Method execution successful.


Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 0;
};

In the output above look for "Method execution sucessful". If your Firewall is enabled on the Client PC then you will get RPC Service Unavailable. I turned my off after getting the error.
So basically this script works successfully on Win 2k8 R2 (Server) and Win7 (Client).

Thursday, August 18, 2011

SharePoint Document Library - Hyperlink

Sometimes you have external content that you would like to make available from your document library without uploading a file. Examples include documents in other SharePoint sites or libraries, and even links to other web pages including SharePoint pages and external web sites.

Turns out SharePoint already has this built-in, just well hidden. There is a built-in Content Type called "Link to a Document". Just add this to your library and then just click the "New" dropdown and select "Link to a Document"! It will simply ask you for a document name and url. You can supply a URL to anything that starts with "http://", including both SharePoint documents and external web pages. It does not support a link to a network share such as "\\myfileserver\folder1\somedoc.doc".
  1. Display your library (Example: Shared Documents)
  2. Click Settings and Library Settings
  3. Click Advanced Settings
  4. Check "Allow management of content types" and then OK
  5. In the Settings page scroll down to Content Types and click "Add from existing site content types"
  6. Select "Link to a Document", click Add and then Click OK
  7. Go back to your library and click the New dropdown and select "Link to a Document"
  8. Enter a display name (Document Name) and the URL (must start with http://) and click OK
Source : http://techtrainingnotes.blogspot.com/2007/08/sharepoint-adding-hyperlinks-to-doc.html

    Tuesday, August 16, 2011

    Manage Virtual Machines Remotely With Hyper-V Manager and Windows 7


    Download the above files and make a folder on Server with a Share (UNC Path i.e. \\pcname\share\) and add the required files hvremote.wsf and the Windows6.1-KB958830-x64-RefreshPkg.msu or Windows6.1-KB958830-x86-RefreshPkg.msu to the shared folder. Make two batch files :-
    1-) HyperVbatchClient.bat

    With following commands with-in :-
    cscript "\\pcname\shared\hvremote.wsf" /mmc:enable

    DISM.exe /Online /NoRestart /Enable-Feature /FeatureName:"RemoteServerAdministrationTools-Roles" /FeatureName:"RemoteServerAdministrationTools" /FeatureName:"RemoteServerAdministrationTools-Roles-HyperV" 

    2-) HyperVbatchServer.batWith following commands with-in :-
    @echo off
    echo
    \\\\\\\\\\\\\\\\---------->Enter Details<----------////////////////
    echo Domain Name or PC Name:
    set /p Domain=
    echo Username:
    set /p UserName=
    cscript "\\pcname\shared\hvremote.wsf" /add:%Domain%\%UserName%


    Now run HyperVbatchClient on client after installing the msu file.
    And then on Server run

    HyperVbatchServer.bat which will ask you for domain or pc name of the server hosting hyper-v and username of the user you want to give access to.

    Hope this helps someone out there.


    Source: http://technet.microsoft.com/fr-fr/library/ee256062(WS.10).aspx

    Oracle VM Virtualbox - Remote Administration

    Been looking for a solution to remote manage Virtualbox vm's. After searching found the right solution :) phpVirtualBox - http://code.google.com/p/phpvirtualbox/

    Easy to install & configure. Had few issues with console window being greyed out and to fix that had to install virtualbox extension pack.

    Steps :-
    1- Download install Xamp
    2- Download and unzip phpVirtualbox in c:\Xamp\htdocs\ (I dumped mine in virtualbox folder)
    3-Change config.php-example to config.php and edit following:-
    • /* Username / Password for system user that runs VirtualBox */
      • Here put in username for the user which is logged into Virtualbox Host Machine. Since I was on domain I tried putting username as "domain\ijaved". However, that does not work so just strip the domain keep username only. i.e. ijaved
        Put password in the password field.
    • /* SOAP URL of vboxwebsrv (not phpVirtualBox's URL) */
      • Here you put the ip address of the VirtualBox host server. You have to run VboxWebSrv.exe on that server in able to connect to the server.
    • // Host / ip to use for console connections
      • Here give the ip address of the VirtualBox host server.
    Install VirtualBox extension pack on the VirtualBox host server to make sure you can use the console. Restart both VirtualBox host and Xamp server just to make sure.. mine didnt work without restart.

    Now you should point to the Xamp server ip address with /virtualbox (should be same folder name you used to unzip)

    Default username and password is admin / admin. You can change it if you want in the config.php file.

    You should be able to see your host and virtual machines once you log in.

    I haven't tried multiple server configuration yet. But when I do I will let you guys know.

    JI