WMI - Clases y propiedades

Hardware classes

Motherboard, controllers, and on-board devices

  • Win32_1394Controller
    • uint16 Availability;
    • string DeviceID;
    • string Manufacturer;
    • string Name;
    • string Status;
  • Win32_BaseBoard
    • string Manufacturer;
    • string Model;
    • string Name;
    • string Product;
    • string Status;
    • string Version; 

C# - Abrir un archivo que lea caracteres unicode




using System;
using System.IO;

namespace prueba
 {
   class jorge
     {
       public static void Main()
         {
           string path = "c:\a.txt";
           // abrir archivo
          StreamReader sr = new StreamReader(path, System.Text.Encoding.Default);
          string linea = sr.ReadLine();
          while (linea != null)
            {
              Console.WriteLine("linea: {0}", linea);
              linea = sr.ReadLine();
            }
          Console.ReadLine();
         }
      }
}


obtener el valor de una variable de entorno de un equipo remoto

$clave = "PATH"
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$s)
$key = $regKey.OpenSubkey("SYSTEM\CurrentControlSet\Control\Session Manager\Environment",$true)
$val = $key.GetValue("$clave")
"el valor de la clave $clave es: $val"

Listar los Domain controllers de un dominio

$dcObj = [adsi]"LDAP://OU=domain controllers,dc=ar,dc=lugsaju,dc=com"
$dcs = $dcObj.PSBase.Children | % { $_.name }
$cantDCs = $dcs.count
$contDC = 0
foreach ($dc in $dcs){
$a = ping -n 1 $dc
$a = $(($a[2]).split("[")[1]).split("]")[0]
write-output "$dc`t$a"
}

con la ip de bonus track

función para nombrar archivos de log - vbscript

Function NomArch(NomArch)    ' Para nombrar los archivos.
Dim arch,hoy,aa,mm,dd
hoy = Date
aa = year(hoy)
mm = month(hoy)
dd = day(hoy)
arch = aa & "_0" & mm & "_" & dd & "_" & NomArch & ".log" ' Formato: \AAAA_MM_DD_NomArch.log
NomArch = arch
End Function

' uso
Set objFS = CreateObject("Scripting.FileSystemObject")
carpeta = "C:\logs"
ArchLogGen = "LogGeneral"
NomLog = NomArch(strArchLogGen)
Set logArchLogGen = objFS.OpenTextFile(carpeta & NomLog, 8,TRUE)

objFS.Close