How to shadow a session on Windows 2012 (R2 only)

How to shadow a session on Windows 2012 (R2 only)

It seems that to Remote Control a user in RDS (shadowing) was removed from Windows Server 2012.

It’s now reintroduced with Windows 2012 R2, I will show you the way using the command line.

Connect to the server with the first mstsc client.

This session will be the shadowed session.
Then on the server, run the following command :

query session

to get the session id of your RDS session.

On the second mstsc client check if the option /shadow is supported.
For instance on my Windows 7 laptop, if I run :

mstsc.exe /shadow

I get :

mstsc /shadow error

shadow option is not supported.
On a W2012 server I get :

it’s supported.

Once you have a client with /shadow option supported, run :

mstsc /v:‹your_server_name› /shadow:‹id_found_above›

On the first msctsc client you will have a prompt :

Just click on “Yes”. You’ve got a shadow !

Testing network path with powershell

Testing network path with powershell

If you want to scan a large list of network path to suppress old references, here is how to do it quickly in powershell.

Beware : if you don’t have authorization on the share the result will be the same as if it doesn’t exist

 

#Network path test
foreach ( $path_to_check in ( Get-Content ./list_path.txt)) {
echo “Scanning -> $path_to_checkif (Test-Path $path_to_check) {
	echo "$path_to_check,yes" >> ./check_path_restult.csv
	}
else {
	echo "$path_to_check,no" >> ./check_path_restult.csv
	}
}

 

 

Example :

 

PS D:\tmp> foreach ( $path_to_check in ( Get-Content ./list_path.txt)) {
>> echo "Scanning -> $path_to_check"
>> if (Test-Path $path_to_check) {
>>     echo "$path_to_check,yes" >> ./check_path_restult.csv
>>     }
>> else {
>>     echo "$path_to_check,no" >> ./check_path_restult.csv
>>     }
>> }
>>
Scanning -> \\host000001\bibli
Scanning -> \\host000001\dom101$
Scanning -> \\host000001\dom33
Scanning -> \\host000001\dom38

 

Content of result file (check_path_restult.csv) :

 

\\host000001\bibli,yes
\\host000001\bibli,yes
\\host000001\dom101$,yes
\\host000001\dom33,no
\\host000001\dom38,yes

Robocopy on slow or busy links using Interframe gap (IPG).

Robocopy on slow or busy links using IPG

Use /IPG:n option to reduce robocopy’s impact on a slow or busy network link.

Between each 64Kb packet, robocopy will wait for n milliseconds so other applications can use the whole bandwidth.

I found an interesting link on zeda.n to calculate the transfert time when IPG delay (the n variable):

http://zeda.nl/EN/Tools/Robocopy_IPG_Calculator/

For instance to mirror a local directory tree to a remote location with a 10ms delay :

robocopy L:\FILES\SHARE\buro \\mynas1\SHARE12\buro /copyall /mir /r:5 /w:10 /log:c:\robo_buro.log /np /IPG:10

PowerShell : Get the most recently modified file for each directories

get the most recently modified file for each directories

The most efficient way to work on Windows is using PowerShell.

You can do virtually anything with it. I’m just a newbie with PowerShell but here is how I work to construct complex commands with some basic knowledge.

Say I have some directories under D:\tmp and I want to know the more recently modified file for each directory.

First I have to list the content of my directory, so I use Get-ChildItem command (get-help Get-ChildItem for more information) :

PS C:\> Get-ChildItem D:\tmp\scripts -Recurse -ErrorAction SilentlyContinue
 
Répertoire : D:\tmp\scripts
 
Mode LastWriteTime Length Name
 
---- ------------- ------ ----
 
d---- 12/07/2012 17:28 LOGS
 
-a--- 12/07/2012 17:28 1421 crdb1.sh
 
-a--- 12/07/2012 17:28 526 crdb2.sh
 
-a--- 12/07/2012 17:28 1245 crdb3.sh
 
-a--- 12/07/2012 17:28 1368 crdb4.sh
 
-a--- 12/07/2012 17:28 613 env.sh
 
-a--- 12/07/2012 17:28 1034 initBDD.ora
 
-a--- 12/07/2012 17:28 651 BDD.sh
 
-a--- 12/07/2012 17:28 169 BDD.sql
 
Répertoire : D:\tmp\scripts\LOGS
 
Mode LastWriteTime Length Name
 
---- ------------- ------ ----
 
-a--- 12/07/2012 17:28 1579 crdb1_BDD.log

-Recurse will list recursively the directory, and -ErrorAction SilentlyContinue will ensure that the script will continue even if an error is raised.

Then I want only to work with files, so I use the property “PsIsContainer “ of the current object in the pipe (which is $_ similarly to Perl language).

I will add the “Where” statement to only select object that are not (so “!”) Containers (directories).

PS C:\> Get-ChildItem D:\tmp\scripts -Recurse -ErrorAction SilentlyContinue | Where {!$_.PsIsContainer}
 
Répertoire : D:\tmp\scripts
 
Mode LastWriteTime Length Name
 
---- ------------- ------ ----
 
-a--- 12/07/2012 17:28 1421 crdb1.sh
 
-a--- 12/07/2012 17:28 526 crdb2.sh
 
-a--- 12/07/2012 17:28 1245 crdb3.sh
 
-a--- 12/07/2012 17:28 1368 crdb4.sh
 
-a--- 12/07/2012 17:28 613 env.sh
 
-a--- 12/07/2012 17:28 1034 initBDD.ora
 
-a--- 12/07/2012 17:28 651 BDD.sh
 
-a--- 12/07/2012 17:28 169 BDD.sql
 
Répertoire : D:\tmp\scripts\LOGS
 
Mode LastWriteTime Length Name
 
---- ------------- ------ ----
 
-a--- 12/07/2012 17:28 1579 crdb1_BDD.log

From here I select the name of the columns I want to display to build a table:

PS C:\> Get-ChildItem D:\tmp\scripts -Recurse -ErrorAction SilentlyContinue | Where {!$_.PsIsContainer}|select Name,DirctoryName, LastWriteTime
 
Name DirectoryName LastWriteTime
 
---- ------------- -------------
 
crdb1.sh D:\tmp\scripts 12/07/2012 17:28:13
 
crdb2.sh D:\tmp\scripts 12/07/2012 17:28:13
 
crdb3.sh D:\tmp\scripts 12/07/2012 17:28:13
 
crdb4.sh D:\tmp\scripts 12/07/2012 17:28:13
 
env.sh D:\tmp\scripts 12/07/2012 17:28:12
 
initBDD.ora D:\tmp\scripts 12/07/2012 17:28:13
 
BDD.sh D:\tmp\scripts 12/07/2012 17:28:12
 
BDD.sql D:\tmp\scripts 20/08/2012 15:52:25
 
crdb1_BDD.log D:\tmp\scripts\LOGS 12/07/2012 17:28:13

Sort them and only keep the most recent file :

PS C:\> Get-ChildItem D:\tmp\scripts -Recurse -ErrorAction SilentlyContinue | Where {!$_.PsIsContainer}|select Name,Dirc
 
toryName, LastWriteTime |Sort LastWriteTime -descending | select -first 1
 
Name DirctoryName LastWriteTime
 
---- ------------ -------------
 
BDD.sql 20/08/2012 15:52:25

Now I have the name and most recently modified file of the directory.

If I want to do that on multiple directories, I will have to loop on every directory.

So I list all the objects of the upper directory and select only the Containers (or Directories).

PS C:\> Get-ChildItem d:\tmp\* | Where {$_.PsIsContainer}
 
Répertoire : D:\tmp
 
Mode LastWriteTime Length Name
 
---- ------------- ------ ----
 
d---- 16/07/2012 15:19 cpu-z_1.55-64bits-en
 
d---- 19/07/2012 18:39 my07xx
 
d---- 07/06/2012 14:47 graphs
 
d---- 12/07/2012 17:28 scripts
 
d---- 01/06/2012 17:24 SDD
 
d---- 15/05/2012 12:05 sqr

Then for each directory found you have to run the previous command. $_ will refer to the current directory on the foreach statement :

PS C:\> Get-ChildItem d:\tmp\* | Where {$_.PsIsContainer} | foreach-object { Get-ChildItem $_ -Recurse -ErrorAction Sile
 
ntlyContinue | Where {!$_.PsIsContainer} | Select Name,DirectoryName, LastWriteTime, Mode | Sort LastWriteTime -descend
 
ing | select -first 1}
 
Name DirectoryName LastWriteTime Mode
 
---- ------------- ------------- ----
 
cpuz_readme.txt D:\tmp\cpu-z_1.55-64bits-en 09/07/2010 15:15:08 -a---
 
check_tinacat.ksh D:\tmp\my07xx 19/07/2012 18:39:18 -a---
 
tmpgraph.png D:\tmp\graphs\graphs\nmon_... 07/06/2012 14:39:04 -a---
 
BDD.sql D:\tmp\scripts 20/08/2012 15:52:25 -a---
 
deploysqrscript.txt D:\tmp\sqr 20/08/2012 16:09:47 -a---

On each line you will have the last modified file found for each directory under directly under “d:\tmp”

Command :

Get-ChildItem d:\tmp\* | Where {$_.PsIsContainer} | foreach-object { Get-ChildItem $_ -Recurse -ErrorAction SilentlyContinue | Where {!$_.PsIsContainer} | Select Name,DirectoryName, LastWriteTime, Mode | Sort LastWriteTime -descending | select -first 1}

How to use iperf for network speed testing – Comment utiliser iperf pour des effectuer des tests de vitesse réseau.

Comment utiliser iperf pour des effectuer des tests réseau

While solving lots of backup issues in my job, I noticed that large number of those was directly related to network issues. Consequently it became a habit to test the network performances of the servers I manage.

Dans mon travail j’ai du résoudre de nombreux problèmes de sauvegarde et j’ai remarqué qu’un grand nombre d’entre eux sont directement liés à des soucis réseau. J’ai donc pris comme habitude de tester les performances réseau des serveurs que j’administre.

Why run network performance tests on your servers:

–          Detect network issue on your servers (wrong Ethernet port configuration, wrong switch configuration …).

–          Detect a global LAN issue (congestion, latency …).

Pourquoi tester les performances réseau de vos serveurs :

–          Pour détecter des problèmes réseau relatifs au serveur directement (configuration du port Ethernet ou du switch …).

–          Pour détecter des problèmes globaux LAN (congestion, latence …).

Why use iperf :

–          Very quick to use: 2 commands and the test is done.

–          Flexible: many options (see below).

–          Iperf exist on both Unix/Linux and Windows platforms.

–          Accurate: iperf doesn’t generate I/O or high CPU load that will distort your test results.

Pourquoi utiliser iperf :

–          Rapide à utiliser : 2 commandes et le test est fait.

–          Flexible : beaucoup d’options.

–          Iperf existe sur plusieurs plateformes.

–          Précis : iperf ne génère pas d’I/O ou charge CPU qui fausseront les résultats des tests.

Handy options:

Options utilies :

-p <port_number> : to change the default port (5001), useful if you are behind a firewall.

-t <seconds> : duration of the test (default is 10s).

-r : run a bidirectional test (up then down).

-d :  run simultaneously a bidirectional test  (up and down at the same time).

You can even launch iperf as a daemon (-D option) on a server so the iperf server will be ready whenever you want to test a client.

 

Options utiles :

-p <port_number> : pour changer le port par défaut (5001), utile si vous êtes derrière un firwall.

-t <seconds> : durée du test (10s par défaut).

-r : lance un test bidirectionnel (montant ensuite descendant).

-d : lance simultanément un test bidirectionnel  (en même temps montant et descendant).

Vous pouvez même lancer iperf en tant que daemon (option –D) sur un serveur. De cette façon le serveur iperf sera prêt à tester des clients à tout moment.

 

Using iperf :

Utiliser iperf :

On one of the servers launch iperf as server:

Sur un des serveurs lancer iperf en mode serveur :

[root@myserver1 root]# iperf -s

------------------------------------------------------------

Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)

 

Then run the test on the other server (in client mode where myserver1 is the name of the server running iperf -s):

Ensuite lancer le test sur l’autre serveur (en mode client où myserver1 est le nom du serveur sur lequel est lancé iperf –s) :

D:\>iperf –c myserver1

------------------------------------------------------------

Client connecting to myserver1, TCP port 5001

TCP window size: 63.0 KByte (default)

------------------------------------------------------------

[1852] local 192.168.1.101 port 36794 connected with 192.168.1.120 port 5001
[ ID] Interval       Transfer     Bandwidth
[1852]  0.0-10.0 sec  1.07 GBytes    921 Mbits/sec

 

Most of the time you will want to run the test with option –r to detect any asymmetric rate issue.

La plus part du temps il faudra lancer le test avec l’option –r pour détecter les problèmes de débit asymétrique :

[root@ myserver3 root] # iperf -c myserver1 -r

------------------------------------------------------------

Server listening on TCP port 5001

TCP window size: 85.3 KByte (default)

------------------------------------------------------------

------------------------------------------------------------

Client connecting to frsu0069, TCP port 5001

TCP window size:   128 KByte (default)

------------------------------------------------------------

[  4] local 192.168.1.102  port 34743 connected with 192.168.1.120 port 5001

[  4]  0.0-10.0 sec    112 MBytes  94.3 Mbits/sec

[  4] local 192.168.1.102  port 5001 connected with 192.168.1.120 port 53073

[  4]  0.0-10.0 sec    112 MBytes  94.1 Mbits/sec

 

You can easily find iperf rpm for you distribution, for Windows and other operating systems here is a link :

Vous pouvez facilement touver le rpm pour votre distribution, pour Windows et les autre systems d’exploitation voice un lien :

iperf download