Category Archives: Administration

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

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>

 

 

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)

Windchill – Folder level access restrction

Windchill provides a way to manage the user/group access to a particular folder. Below are the steps to follow to provide/deny the access to a folder.

  1. Create an ACL with desired access permissions from policy administration.
  2. Go to the folder where the access restrictions should be applied and right click on the name
  3. Select “Edit” and uncheck the “Inherit domain from parent
  4. Click on find and select the ACL from the pop-up and click on OK
  5. Click on OK on “Edit Folder” pop-up

This applies the ACL to the folder.

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.

 

 

Windchill: How to deploy SSL certificate

One fine day our SSL certificate was expired and we need to update our Windchill solution with new one. A quick Google search shows that not much information available outside the Winchill own forums. Therefore I am writing down my steps to deploy new SSL certificate for Windchill. Our Windchill solution version is 10.2 and running on Windows 2008 Server R2 VM. So all my steps are in that OS context.

The whole procedure is two step solution, first we need to extract CRT and KEY files from PFX file and second is to set up HTTPD.

Extract CRT and KEY files from PFX 
  1. Open Command Prompt
  2. CWD to <Windchill Dir>\HTTPServer\bin
  3. EXEC openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]
  4. System prompts for password and pass phrase for the certificate. Enter the same as password that is with PFX file.
  5. EXEC openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]
  6. Now you will find both CRT and KEY files in the target folder. For windchill, we need to give unencrypted key file.
  7. EXEC openssl rsa -in <filename1>.key -out <filename2>.key
Setting up the HTTPD
  1. Change both CRT and KEY file names as “server.crt” and “server.key” respectively
  2. Now stop the Windchill and close the HTTPD
  3. Move the CRT file into <Windchill Dir>\HTTPServer\conf\extra\ssl.crt\
  4. Move the KEY file into <Windchill Dir>\HTTPServer\conf\extra\ssl.key\
  5. CWD to <Windchill Dir>\Java\bin
  6. EXEC keytool -import -alias Windchill -file <Windchill Dir>\HTTPServer\conf\extra\ssl.crt\server.crt -storetype jks -keystore <Windchill Dir>\Java\jre\lib\security\cacerts
  7. System prompts for password, type your key store password.
  8. If system prompts as “alias already exists“, then choose a new alias for the certificate
  9. System prompt for Trust this certificate, type “yes
  10. Now, open file “<Windchill Dir>\HTTPServer\config.xml” and look for “<property name=”certAlias”” set the value as the same alias that given in previous step.

Windchill: How to chang between HTTP and HTTPS

In the process of making our Windchill solution more secure, we are turning it over to HTTPS. After deploying the SSL certificate now its time to targeting its web interface to HTTPS. I followed below procedure to achieve that.

  1. From the Windchill administration shell do the following
    1. xconfmanager -s wt.webserver.protocol=https -t codebase/wt.properties
    2. xconfmanager -s wt.webserver.port=443 -t codebase/wt.properties -p
    3. xconfmanager -s wt.server.codebase=$(wt.webserver.protocol)://wcp.omnioffshore.com/$(wt.webapp.name) -t codebase/wt.properties -p
  2. Start httpd (with SSL for HTTPS else without SSL)

Windchill: Database Configratation

In the event of disaster recovery, if the database instance name was changed then the Windchill configuration file must be updated with those changes. Following is the way we changed our Windchill configuration;

    1. Stop Windchill by issuing “Windchill stop” command at Windchill command prompt.
    2. Issue the following commands at windhill prompt
      1. Xconfmanager –s wt.pom.jdbc.host=<Host Name / IP Address> –t codebase\wt.properties -p
      2. Xconfmanager –s wt.pom.jdbc.port=<Oracle Listener Port> –t codebase\wt.properties -p
      3. Xconfmanager –s wt.pom.jdbc.host=<Oracle Service Name> –t codebase\wt.properties -p
    3. Now start windchill by issuing  “Windchill start” at Windchill command prompt