Posts Tagged ‘Windows’

Configure Windows 2012 server to use NTP server.

I used the following procedure to configure my Windows 2012 server to use NTP running on my linux server.

Configure the Window Time service to use the NTP server:

PS > w32tm /config /manualpeerlist:NameOrIPAddress /syncfromflags:MANUAL

Example:

PS > w32tm /config /manualpeerlist:192.168.0.1 /syncfromflags:MANUAL

Stop the Windows Time service:

PS > Stop-Service W32Time

Start the Windows Time service:

PS > Start-Service W32Time

Query the Windows Time service:

PS > w32tm /query /status

Convert UTF-16 file to UTF-8

A lot of times, I find myself creating output files in Windows that I want to use linux to parse because I am more comfortable scripting in linux than in Windows. Most times I the output UTF-16 encoded. You can tell by using the file command. I used this to convert a file generated in Windows 2003 server, so that I could work with it in CentOS 6.x.

$ file myfilename.txt
myfilename.txt: Little-endian UTF-16 Unicode text, with CRLF line terminators

Then, to convert the file:

$ iconv -f utf-16 -t utf-8 myfilename.txt > mynewfilename.txt

Transferring Flexible Single Master Operations (FSMO) roles

Since I don’t have to do this very often, but always seem to forget how to transfer the Schema Master and Domain Naming Master, I decided to write it down, when it came up again as I transferred all the roles to my Windows 2012 server.

The following three FSMO roles can be migrated from Active Directory Users and Computers. Right mouse click on the domain and select Operations Masters. There is one tab for each of the three FSMO roles:

PDC
RID Pool Manager
Infrastructure Master

The following FSMO role can be transfered from Active Directory Domains and Trusts. Right mouse click on Active Directory Domains and Trusts, and select Operations Master.:

Domain Naming Master

For the Schema Master FSMO role, you first need to register a dll by executing the following command (Note: This only needs to be done once from an elevated command prompt.):

c:\> regsvr32 schmmgmt.dll

Then, you can add the Active Directory Schema Snap-In to a Microsoft Management Console (MMC). With the Snap-In added, ensure that the targeted domain controller is the one that you want to transfer the Schema Master role to. To change it, right mouse click on Active Directory Schema, under Console Root, and select Change Active Directory Domain Controller.. to select the domain controler you want to transfer the role to. Once that is done, right mouse click on Active Directory Schema, and select Operations Master to change the role.

If you do not have a different domain controller targeted, you will get the following message:

The current Active Directory Domain Controller is the Operations Master. To transfer the Operations Master to a different DC, you need to target Active Directory Schema to that DC.

And when you switch the target domain controller, you get the following, which is okay for what we want to do.:

Active Directory Schema snap-in is not connected to the schema operations master. You will not be able to permform any changes. Schema modification can only be made on the schema FSMO holder.

Windows screen orientation

You ever hit a series of keys on your Windows 7 keyboard and find your display orientation upside-down or side ways? Well, what you more than likely did was hit Ctl-Alt and one of your arrow keys. To get orientation right again, do Ctl-Atl-Up.

Add a Windows 2003 shared printer to a Windows 7 client.

While trying to connect to shared printer on a Windows 2003 server (32 bit) from a Windows 7 (32 bit) client, I kept getting a “Windows cannot connect to the printer. Operation failed with error 0x0000002.” I stumbled on an interesting little trick to get around this issue.

First, I created the printer locally and allowed Windows 7 to install the appropriate driver. After the printer has been created, I went into the printer Properties and clicked on the Ports tab. Then, Add Port… Select Local Port, and click New Port… Enter the UNC to the printer share name. For example, \\servername\printersharename.

Then, the printer worked an used the Windows 2003 print share. It is not the cleanest solution, but it does get the printer working using the shared printer on the Windows 2003 server.

Windows Logon script from local policy.

I keep forgetting the location of this setting, so I am documenting it so I can find it easilly next time.

Tested on Windows 7.

To configure a Windows computer to execute a login script whenever anybody logs in to the machine, you can you use the Local Group Policy Editor. From the command prompt or “Search programs and file”, launch the Local Group Policy Editor by entering gpedit.msc. Then, navigate to User Configuration\Windows Settings\Script (Logon/Logoff). Double click Logon, and add the script. Note: you can use PowerShell scripts as well, but do that under the PowerShell Scripts tab so the correct command line interpreter is used. Also, if you have user specific portions of the script, you should construct the logic of your script as such. The Logoff option works the same way.

Create a bootable USB flash drive to install Windows.

Finally, I have discovered a very simple utility from Microsoft to create a bootable USB flash drive to install Windows. I used this to create a Windows 2008R2 installable flash drive, and it works great. However, this utility only seems to work for certain versions of Windows, and only Windows.

http://www.microsoftstore.com/store/msstore/html/pbPage.Help_Win7_usbdvd_dwnTool

Hyper-V lessons

I started looking into Hyper-V, and learned something quick. I installed Windows 2008 R2 Hyper-V on a server. Then, I used a Windows 7 client to access the host via the Hyper-V Manager. I created a virtual machine and installed an operating system, but found that I had no network connection. I had to configure the host network interfaces via the Hyper-V Manager Virtual Network Manager. Once I did this, I was able to adjust the network interface on my virtual machine to use the newly configured interface.

Installing RHEL6 on a Hyper-V server presented some new challenges as well. I was able to install the OS easily enough. The problem came when I actually tried to use it. There was no virtual network interface card driver loaded. I had to download and install the Linux Integration Services software from Microsoft. It is a 2.2MB ISO image, so you can either put it on CD/DVD, mount it from a flash drive or use it as your virtual CD drive (which I did).

From the RHEL6 VM:
# cd /media # If /media is the mount point you used.
# ./install.sh
# shutdown -r now

Now, in my case, I did a minimum install, so maybe it is different when you do a basic install, but I had to manually create the ifcfg-eth0 and network files. For now, I just wanted to get on the network, so I used a DHCP client configuration.

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

# vi /etc/sysconfig/network
GATEWAY=192.168.0.1

# service network restart
or
# shutdown -r now
or
# ifup eth0

Delete a Windows user’s local profile

Right click on Computer and go to Properties.
Click Change Settings .
In the System Properties dialog box, click the Advanced tab.
Under User Profiles , click Settings .
In the User Profiles dialog box, select the profile that you want to delete, click Delete , and then click OK .

Locate and then expand the following registry subkey:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

Right-click the SID that you want to remove, and then click Delete .

Log on to the computer and create a new profile.

Windows 2003/2008 shutdown command

Because I never remember the syntax for 2003 and later:

Reboot:
shutdown /r /c “comment” /t time

Shutdown:
shutdown /s /c “comment” /t time

Add a /m computername to reboot/shutdown a remote server.

Return top

INFORMATION