Category Archives: HOWTO

Windows: “The network folder specified is currently mapped using a different user name and password”

When I try to map a network folder as a network drive in 2008 Server, I was greeted with  following

“The network folder specified is currently mapped using a different user name and password”

The issue is due to me already opened the network path in windows explorer with a different credentials. Due to this there is a clash when I try to map the same network path as network drive, because I entered a different credentials to connect.

To fix this issue you need to manually delete the existing connection. Even you close the windows explorer which opened the network path does not help. To close the connection, open command prompt and type following command;

net use /delete \\server\share

This closes the existing connection so that you can create the network drive successfully.

Advertisements

ORACLE: How to escape special characters

We often need to escape special characters while retrieving the rows. To do that there are two ways;

  1. Use “SET ESCAPE ‘{ESC CHAR}’
  2. End the select statement with ‘ESCAPE ‘{ESC CHAR}’

For example;

SELECT SL.SYSTEM_CODE, SL.SYSTEM_DESCRIPTION, SL.SYSTEM_PARTICULARS FROM SYSTEMS_LIBRARY SL WHERE SL.SYSTEM_CODE LIKE 'UOTE\_%' ESCAPE '\'

the above statement returns all the systems with system code like ‘UOTE_’. But i cannot use the underscore directly in the quotes. Therefore I want to escape it with \ and tell Oracle to treat it as escape character by typing “ESCAPE ‘\'” at the end of the select statement.

APPCMD: IIS Over Console

When we do remote deployment what more convenient than a console? Once I got an opportunity to remotely deploy the web application along with supporting subsystems. Therefore I need a batch file to automate the whole deployment procedure.

One of the requirement is to setup IIS with new app pool, create VD and deploy the files needed to run the website. Following is the command to manage IIS over command prompt;

APPCMD
  1. To list all existing app pool from IIS use
    APPCMD LIST APPPOOL
  2. To create a new app pool then use
    APPCMD ADD APPPOOL /NAME:<NAME_OF_APPPOOL>
  3. To create app pool with integrated pipeline use
    APPCMD ADD APPPOOL /NAME:<NAME_OF_APPPOOL> /MANAGEDPIPELINEMODE:”Integrated”
  4. To create app pool with specific .NET version, use
    APPCMD ADD APPPOOL /NAME:<NAME_OF_APPPOOL> /MANAGEDRUNTIMEVERSION:”v4.0″.
  5. In this case I am using .NET Framework 4.0
  6. To enable 32-bit dlls use the flag
    /ENABLE32BITAPPONWIN64:”true”
  7. To finally create the site,
    APPCMD ADD APP /SITE.NAME:”Default Web Site” /PATH:/<VD_NAME> /PHYSICALPATH:<PHYSICAL_PATH_TO_VD> /APPLICATIONPOOL:<APP_POOL_NAME>

 

 

ORACLE: View compiled with errors

Many times when ever we try to create the views under Oracle, often end up with messages like “View created with warnings” or ” View compiled with errors”. But SQL Developer does not reveal the error. In such cases to know the error actually generated fire the following query in SQL Developed or SQL Plus prompt;

SELECT TEXT FROM DBA_ERRORS WHERE NAME='VIEW_NAME_HERE'

If you have same view name in more than one schema then put that target schema name as

AND OWNER='SCHEMA_NAME'

This table always contains most recent error raised on that object.

Power Shell: Remote session

This is a very common activity for any system administrator to remotely connect a computer and perform the administrative tasks. PowerShell offers an excellent opportunity to do exactly the same.

To remotely connect to any computer use the below command in the PowerShell

Enter-PSSession -ComputerName XXXX -Credential YYYY

Here XXXX is the computer name or IP of the remote computer and YYYY is the user name with which you want to login. This delivers the remote PS session to the remote computer if the given computer is in TrustedHosts list of WINRM. If not Powershell throws an exception as below;

image

In that case, we need to add the remote computer to the trusted hosts of WINRM. To do that, issue the below command;

winrm s winrm/config/client '@{TrustedHosts=&quot;RemoteComputer&quot;}'

Here the “RemoteComputer” is the name or IP of the computer to which you want to connect.

image

Now execute the Enter-PSSession command to invoke a remote PS session to the remote computer.

image

Now you have the remote command shell (Power Shell)

Powershell: How to manage Hyper-V VMs in Windows 10

I am using Windows 10 since it’s first release. So far I am happy with it and had no issues. With it comes Hyper-V to deploy VMs. I normally do not install 3rd party tools until its absolutely necessary. Therefore I started using Hyper-V to run my DB server as well as Linux servers.

To manage VMs under Hyper-V, we have two options. One is to use “Hyper-V Manager” and second one is to use “Power Shell”. First one is pretty common and easy to use, but that second method is very interesting. The following post is about what i have learned so far the commandlets to work with Hyper-V. I know the following is not full information but I keep updating this post with latest information. So lets jump in;

Show all VMs under Hyper-V:

To list all the VMs available under Hyper-V, use the following command;

 get-vm

This command list all the VMs available under Hyper-V. Here is the output;

image

In my case  I have Windows 2003 as my DB server and Ubuntu 15.10. Here, VM is short form of Get-VM.

Start a VM:

To start a VM, fire the following command;

start-vm win2k3

The above command starts the VM with the name “win2k3”. Powershell shows a progress bar on top of the screen. The following is the current status of my VMs. Look at the status of VM WIN2K3;

image

Save a VM:

In order to save the current VM state, simply issue the below command;

 save-vm win2k3

This command saves the current status of the VM and again Powrshell shows a progress bar to indicate the progress. Now look at my current state of VMs

image

Stop a VM:

Now you pretty much guessed the next command;

stop-vm win2k3

The above command, stops the running VM. If the current sate of the VM is “Saved” and if you issued this command to stop the VM then Powershell prompts you with the following;

Confirm

Hyper-V can’t shut down virtual machine “WIN2K3” because the Shutdown integration service is

unavailable. You can turn off the virtual machine by selecting [Y]es, but this is similar to

pulling the power on a physical machine. To avoid potential data loss, select [N]o, then pause

or save the virtual machine. Do you want to turn off the virtual machine?

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is “Y”):

Therefore make sure the VM is in running state before you issue this command. Now check my current VM state;

image

Take a Snapshot

To take the snapshot fo the VM, issue the following command;

 checkpoint-vm -VMName win2k3

For more awesome Hyper-V commands visit here.