PowerShell e Arquivos INI/PowerShell and INI Files

16 10 2008

Mais uma dica. Com o .NET Framework há uma tendência de ir jogando configurações para arquivos XML ao contrário de arquivos INI, como antigamente muito se usou. Mas como sempre é possível ter a necessidade de usar/configurar programas antigos, em [1] são mostrados 3 scripts que juntos ajudam na tarefa de manipular arquivos INI.

O primeiro (Invoke-WindowsApi.ps1) é um workaround para se usar a API Windows no PowerShell. Não há no .NET Framework uma classe que lide com arquivos INI diretamente, então nos dois scripts seguintes (Get-PrivateProfileString.ps1 e Set-PrivateProfileString.ps1) é possível usar passando somente os parâmetros necessários.

Segue o código dos scripts (Thanks Lee!):

=============================================

One more tip. With .NET Framework there is a tendency to throw application settings for XML files as opposed to INI files, as much has been used previously. But as you can always have the need to use/configure older programs, in [1] are shown 3 scripts that together help in the task of manipulating INI.

The first (Invoke-WindowsApi.ps1) is a workaround to use the Windows API into PowerShell. There is no .NET Framework a class that deals with INI files directly, then in the following two scripts (Get-PrivateProfileString.ps1 and Set-PrivateProfileString.ps1) you can use only those passing the required parameters.

Below goes the code of scripts (Thanks Lee!):

 

==================================

 

[1] Managing INI Files with PowerShell





Load caracterization – 2nd Part / Caracterização de carga – 2nd

14 07 2008

Again I’m here to talk a bit ’bout this problem and now there’s a good new! I’ve found a toolkit, (a bit old, but it’s ok) that solves my problem on listing the disk activity. Lucky mine, ’cause I defined my data before knowing it was possible to collect data in that way.

I’m talking ’bout sysinternals [2] that consists on a collection of small softwares, that monitors or tweaks a system. Be careful on using it, because some applications produce a huge data collection activity, they can stop the machine.

On my problem, what I need to discover is a sequence of disk access in a trace, this information is held by Windows Kernel, and is a bit difficult to retrieve. In sysinternals suite, there’s a diskmon app, that monitors disk activity, in the way below:

image

See that the output is in the form: time, duration of a request, in witch disk a request were done, the type of request (write, read), the sector (read/written) and the lenght.

Now, this solves the problem i’ve talked ’bout here

=================================================

“>Mais uma vez estou aqui para falar um pouco sobre este problema, e agora há uma boa notícia! Encontrei um kit de ferramentas, (um pouco velho, mas tudo bem), que resolve o meu problema com a lista de atividade do disco. Sorte minha, por eu definir a métrica antes de saber se era possível recolher os dados dessa forma como planejei

Eu estou falando do sysinternals [2] que consiste em uma coleção de pequenos softwares, que monitoram ou ajustam um sistema. Tome cuidado ao usar, pois algumas aplicações produzem uma enorme atividade de recolha de dados, que podem parar a máquina.

Em meu problema, o que eu preciso descobrir é uma seqüência de acesso em um trace de disco, informação esta que existe no Kernel do Windows, e portanto é um pouco difícil de recuperar. Na suite sysinternals, há um aplicativo discmon, que monitora atividade de disco, na forma como na figura:

 

=============

[1] http://live.sysinternals.com/
[2] http://technet.microsoft.com/en-us/sysinternals/default.aspx
[3] http://technet.microsoft.com/en-us/sysinternals/bb896646.aspx