Archive

Archive for the ‘Microsoft’ Category

Quickie: Pipe output into Clipboard

September 24th, 2014 No comments

I just found one cool utility. It’s called clip.exe. You can use this utility to input the content from pipline into clipboard and then paste the content of clipboard where ever you want.

Here a example:

ipconfig /all | clip

When you run this all the output from command “ipconfig /all” is stored into windows clipboard. Now you can Paste (CTRL+V) this into any application you want.

When you want to read the content of any file into windows clipboard you can use following command:

clip < C:\kukuc.txt

This cool utility came with Windows Server 2003 (not in Windows XP) and stayed there until Windows 8 and Windows Server 2012 R2.

Have a good day,

 

 

Categories: Quickie, Windows Tags: , , ,

PowerShell: Script to check for logged users

September 16th, 2014 No comments

I’m creating couple powershell scripts which I use in my work. I want to share couple of them with you. So here is a script which look for domain computers and then check who is logged on those online machines.

$ADSearchBase = "OU=Computers,DC=domain,DC=local"
$ADFilter = "*"

Function Get-LoggedUsersOnComputers
  {
  $ADComputersList = Get-ADComputer -SearchBase $ADSearchBase -Filter $ADFilter
  foreach ($ADComputer in $ADComputersList)
    {
    Write-Output $ADComputer.Name
    Try
       {
       $ExplorerProcesses = Get-WmiObject -ComputerName $ADComputer.Name -Class win32_process -Filter "Name='explorer.exe'" -ErrorAction Stop
       }
     Finally
       {
       If ($?)
         {
         foreach ($ExplorerProcess in $ExplorerProcesses)
           {
           Write-Output "  $($ExplorerProcess.GetOwner().User)"
           }
         }
       Else
         {
         Write-Output "  <<< Could not connect"
         }
       }
    }
  }

Get-LoggedUsersOnComputers

If you have any remark on my script, please, let me know. I will be happy to make it more cute 🙂

Powershell Web Access

September 8th, 2014 1 comment

I was playing today with new feature called PowerShell Web Access. This feature was brought in Windows Server 2012. It is very easy to install and easy to use. You need to select one server which will act as Web Access PowerShell gateway server. You will be connecting to this server using SSL and this server will use PowerShell remoting to access computers inside your network. So let’s make it work.

First you need to run PowerShell as a admin on gateway server:

PowerShell

Let’s look for Windows features which contain word “shell”:

PowerShell

Windows PowerShell Web Access is the feature we want to install. So let’s install it:

PowerShell

Now we can look at this website to lear more, but let’s play more. Now we have new cmdlets containig word “pswa” (PowerShell Web Access):

PowerShell

We installed pswa feature, but this feature didn’t install its web component into the server. So let’s install pswa Web application using cmdlet Install-PswaWebApplication with parameter -UseTestCertificate. This parameter creates self-signed SSL certificate for this new site, you can use your own certificate. Be aware that this certificate expires in 90 days.

PowerShell

New website was created:

PowerShell

By default no one can use Powershell access gateway. You need to define explicit rules who, where and what can do. For easy test you can use following rule for domain group called GRP_PowerShell_Remote to access all computers with all permissions:

PowerShell

Now everything is prepared. We need to make some changes in network (routers and NAT) to be able to access 443 port on server from Internet. Now when we open site, we can see:

PowerShell Web Access

And now you can work on machines inside your network. It’s secure and reliable:

PowerShell

This is very nice and cute feature.

I hope you will start to use and enjoy it.

Have a nice day.

 

Storage Explorer

August 27th, 2014 No comments

Hello folks

Today I found one really nice utility at Windows Server 2008 R2 and up. It’s called Storage Explorer. It’s MMC snap-in which enables you to see what your fiber optic cards (HBAs) on fiber optic fabrics.

You can see information about your HBAs:

Storage Explorer

This utility somehow connected into fibre optic switch and listed its ports and WWNs connected to it:

Storage Explorer

And also found some information about optical switch (for example management IP address):

Storage Explorer

I know this tool is not as powerfull as Brocade SANHealth, but it’s bettern than nothing 🙂

That’s all folks for today,

DFSR not copying all temporary files

June 6th, 2014 3 comments

I implemented DFSR replication in our customer between two locations. There are people opening same files on both locations and they want to use Office document locking feature. This locking mechanism is based on creation of temporary files (~*). So I removed file exception (~*) from DFSR Replicaiton Group and allowed to replicate temporary Office files. When I create and open Word document on one location two files are were: WORD.docx and ~$WORD.docx. And when I created new Excel document two files were created: EXCEL.xlsx and ~$EXCEL.xlsx.

Creation of temporary filesOn other location only two files were replicated (created): WORD.xlsx and ~$WORD.xlsx:

Replicated filesWhen I closed Word and Excel temporary files dissapeared and docx and xlsx files replicated correctly.

So let’s look why those files were not replicated. In some Technet articles I found that DFSR doesn’t replicate temporary files. More info is here and here.

It’s nice to know that DFSR doesn’t replicate files marked as temporary. So let’s look at those opened Word and Excel files.

WORD.docx

File attrib

– Only archive attribute set (0x20)

~$WORD.docx:

File attrib– Archive attribute (0x20) and Hidden (0x02)

EXCEL.xlsx

File attrib– Only archive attribute set (0x20)

~$EXCEL.xlsx

File attrib

So utility fsutil cannot open data from this file. It looks that Excel opens its files different way as Word does. And that’s why file ~$EXCEL.xlsx didn’t copy to other location, because DFSR cannot access this file while it’s opened in Excel.

This Excel behaviour causes that Office locking mechanism is not working over DFSR.

Let’s hope Microsoft will fix this in other release Office 🙂

Have a nice day,

Quickie: How to delete registry using reg file

June 6th, 2014 No comments

I always used .reg files to import registry keys and values. I started to think if it’s possible to delete registry key or value using .reg file.

To create key and value you can use following .reg file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\test]
“test_value”=dword:00000010

 

To delete only value “test_value” you can run following .reg file (minus sign after the equal sign):

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\test]
“test_value”=

 

To delete whole key you can run following .reg file (minus sign in front of key name):

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\test]

 

That’s all for now,

 

Problem with issuing certificate to domain controllers

June 6th, 2014 No comments

I have experienced same problem in two customers within four days. I had server with operating system Windows Server 2012 R2. I installed role Active Directory Certificate Services with default settings. Also default certificate templates were installed. One of the default certificate templates is called Domain Controller and it should be enrolled automatically to all domain controllers using autoenrollment method.

Certification Template

Certificates didn’t autoenroll to domain controllers so I tried to enroll certificate manually. I received following error:

Error: The RPC server is unavailable. 0x800706ba (WIN32: 1722 RPC_S_SERVER_UNAVAILABLE)

CA Error

After couple of minutes of debugging I found out that it should have something to do with security of accessing DCOM object. When I have looked on DCOM security settings I found some domain group called CERTSVC_DCOM_ACCESS. I tried to google for this and I found out that this group should contain all domain members that want to enroll certificate using DCOM. And it was missing “Domain Controllers” group:

certsvc_dcom_access

I just inserted group “Domain Controllers” into domain group CERTSVC_DCOM_ACCESS. Rebooted domain controllers, they had to get new group membership, and everything started to work as expected.

More info here and here.

That’s all for today,

Thumbs.db locked DFSR

May 21st, 2014 3 comments

Problem

I had one problem with DFSR. I had two servers. Server01 in located in Location01 and Server02 located in Location02. There is DFSR Replication Group configured between those two servers. Replication worked in one direction – from Server01 to Server02, but it didn’t work from Server02 to Server01.

Findings

When I looked into backlog of Server02 using command:

dfsrdiag backlog /rgname:Rep_Group /rfname:Rep_Folder /SendingMember:SERVER02 /Receivingmember:SERVER01

I found out that there is lots of files stuck in queue – backlog. All of them were called Thumbs.db. These files are used by Windows Explorer to store thumbnails of files in directories.

Solution

I fixed issue by clearing conflict directory using following commands. I had to find out GUID for my replication folder:

wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderconfig get replicatedfolderguid,replicatedfoldername

And then run procedure to clear conflict directory:

wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderinfo where “replicatedfolderguid=’GUID’” call cleanupconflictdirectory

After directory clearance replication stared to work.

But I wanted to prohibit to create Thumbs.db files on network shares. I don’t know about any setting that would disable it on client machines so I had to restrict creation on servers. I decided to create File Screen to prohibit Thumbs.db creation on servers.

1. On server go to Server Manager — Roles — File Services — Share and Storage Management — File Server Resource Manager — File Screening Management:FS01

2. Right-click on File Groups and create new File Group:

– Name it

– Include file “Thumbs.db” into list

FS02

3. Right-click on File Screen Templates and create new screen template:

– Name it

– Make sure you have selected Active screening

– Select new created group “Thumbs.db”

FS03

4. Enable file screening on directory. Right-click on File Screens and create file screen.

– Select Path where File Screen should apply

– Select new created File Screen Template

FS04

And screen file is sucessfully set.

One more step I took was delete all Thumbs.db files from server’s disk. I run following powershell command in share directory:

Get-ChildItem -Force -Recurse | where { $_.Name -like “Thumbs.db”  } | Remove-Item -Force

And that’s all for today play with DFSR.

Quickie: Couple helpful command for DFSR

May 21st, 2014 No comments

Today I was solving issue with not replicating DFSR server in Full Mesh topology. Here are couple helpful commands to work with DFSR:

To look if any replication is in progress:

dfsrdiag replicationstate

To look if there is anything in backlog:

dfsrdiag backlog /rgname:Rep_Group /rfname:Rep_Folder /SendingMember:SERVER01 /Receivingmember:SERVER02

To disable debug logging:

wmic /namespace:\\root\microsoftdfs path dfsrmachineconfig set enabledebuglog=false

To set maximum debug files:

wmic /namespace:\\root\microsoftdfs path dfsrmachineconfig set maxdebuglogfiles=2000

To set maximum lines in one log file:

wmic /namespace:\\root\microsoftdfs path dfsrmachineconfig set maxdebuglogmessages=400000

To look for replication folder GUID:

wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderconfig get replicatedfolderguid,replicatedfoldername

To clean up conflict directory:

wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderinfo where “replicatedfolderguid=’GUID'” call cleanupconflictdirectory

That’s all folks for today,

Categories: Microsoft, Quickie, Windows Tags: , ,

Quickie: Right click using keyboard

April 29th, 2014 No comments

In my class today we needed to do right-click in Windows using keyboard. I just found out that Shift + F10 simulates right-click 🙂

That’s all for today,