none
Dateien in TXT ausgeben RRS feed

  • Frage

  • https://www.gutefrage.net/frage/wie-bekomme-ich-es-hin-jeden-netzwerkadapter-in-eine-seperaten-zeile-auszugeben-siehe-details?foundIn=my_stream
    Donnerstag, 1. September 2016 08:29

Antworten

  • So etwas würde funktionieren:

    $reportnet  = @()
    
    foreach ($network in (get-WMIObject win32_networkadapter | select PSComputerName,Caption,Installed,Manufacturer)) {
        $reportnetObj = New-Object PSObject
        $reportnetObj | Add-Member NoteProperty -Name "Name" -Value $network.Caption
        $reportnetObj | Add-Member NoteProperty -Name "Computer" -Value $network.PSComputerName
        $reportnetObj | Add-Member NoteProperty -Name "Aktiviert" -Value $network.Installed
        $reportnetObj | Add-Member NoteProperty -Name "Hersteller" -Value $network.Manufacturer
        $reportnet += $reportnetObj
    }
    $reportnet | Out-File -Encoding utf8 C:\Networkadapter.txt 


    Evgenij Smirnov

    msg services ag, Berlin -> http://www.msg-services.de
    my personal blog (mostly German) -> http://it-pro-berlin.de
    Windows Server User Group, Berlin -> http://www.winsvr-berlin.de
    Mark Minasi Technical Forum, reloaded -> http://newforum.minasi.com

    In theory, there is no difference between theory and practice. In practice, there is.

    • Als Antwort markiert Leinadgnom Donnerstag, 1. September 2016 09:39
    Donnerstag, 1. September 2016 09:21

Alle Antworten

  • Moin,

    hilfreich wäre auch der Teil des Skriptes, in dem Du die Daten ausliest, sowie die Initialisierung von $reportnet und die von Dir weggelassene Schleife.


    Evgenij Smirnov

    msg services ag, Berlin -> http://www.msg-services.de
    my personal blog (mostly German) -> http://it-pro-berlin.de
    Windows Server User Group, Berlin -> http://www.winsvr-berlin.de
    Mark Minasi Technical Forum, reloaded -> http://newforum.minasi.com

    In theory, there is no difference between theory and practice. In practice, there is.

    Donnerstag, 1. September 2016 08:55
  • $processor = get-WMIObject win32_processor | select PSComputerName,DeviceID,Status,MaxClockSpeed,ProcessorType,Caption,Manufacturer,NumberofCores,ProcessorId,Role
    $cdrom = get-WMIObject win32_CDRomDrive | select PSComputerName,Drive,Status,Caption,Description,Manufacturer,MediaType
    $volume = get-WMIObject win32_volume | select PSComputerName,Automount,BlockSize,BootVolume,Capacity,Caption,FileSystem,FreeSpace,Label,MaximumFileNameLength,Name,SerialNumber,SystemVolume
    $sound = get-WMIObject win32_sounddevice | select PSComputerName,Name,Status,Caption,Manufacturer,ProductName
    $battery = get-WMIObject win32_battery | select PSComputerName,Caption,DesignVoltage,DeviceID,Name,Status
    $portbattery = get-WMIObject win32_portablebattery | select PSComputerName,Caption,DesignCapacity,DesignVoltage,DeviceID,Location,Manufacturer,Name,SmartBatteryVersion
    $network = get-WMIObject win32_networkadapter | select PSComputerName,Caption,Installed,Manufacturer
    $os = get-WMIObject win32_operatingsystem | select PSComputerName,Status,Name,FreePhysicalMemory,FreeSpaceInPagingFiles,FreeVirtualMemory,BootDevice,BuildNumber,BuildType,Caption,CountryCode,CSDVersion,EncryptionLevel,Manufacturer,MaxNumberOfProcesses,MaxProcessMemorySize,MUILanguages,Organization,OSArchitecture,Primary,SerialNumber,SystemDirectory,SystemDevice,TotalVisibleMemorySize,TotalVirtualMemorySize,Version,WindowsDirectory
    $bios = get-WMIObject win32_bios | select PSComputerName,Status,Caption,BIOS,CurrentLanguage,Manufacturer,PrimaryBIOS,SerialNumber,Version
    $Mainboard = get-WMIObject win32_baseboard | select PSComputerName,PoweredOn,Caption,Manufacturer,Product,SerialNumber
    $report = @()
    $reportnet = @()
    $reportObj = New-Object PSObject
                $reportObj | Add-Member NoteProperty -Name "Geraet" -Value "PROZESSOR"
    			$reportObj | Add-Member NoteProperty -Name "Abkuerzung" -Value $processor.Role
    			$reportObj | Add-Member NoteProperty -Name "Computer" -Value $processor.PSComputerName
                $reportObj | Add-Member NoteProperty -Name "Name" -Value $processor.Caption
    			$reportObj | Add-Member NoteProperty -Name "ID" -Value $processor.ProcessorId
    			$reportObj | Add-Member NoteProperty -Name "GeraeteID" -Value $processor.DeviceID
    			$reportObj | Add-Member NoteProperty -Name "Hersteller" -Value $processor.Manufacturer
    			$reportObj | Add-Member NoteProperty -Name "AnzahlKerne" -Value $processor.NumberOfCores
    			$reportObj | Add-Member NoteProperty -Name "Mhz" -Value $processor.MaxClockSpeed
    			$reportObj | Add-Member NoteProperty -Name "Bauart" -Value $processor.ProcessorType
    			$reportObj | Add-Member NoteProperty -Name "Status" -Value $processor.status
    			$report += $reportObj
    			$report += "
    -----------------------------------------------------
    			"
    $reportObj = New-Object PSObject
    			$reportObj | Add-Member NoteProperty -Name "Geraet" -Value "CD-ROM-LAUFWERK"
    			$reportObj | Add-Member NoteProperty -Name "Beschreibung" -Value $cdrom.description
    			$reportObj | Add-Member NoteProperty -Name "Computer" -Value $processor.PSComputerName
    			$reportObj | Add-Member NoteProperty -Name "Laufwerk" -Value $cdrom.Drive
    			$reportObj | Add-Member NoteProperty -Name "Name" -Value $cdrom.Caption
    			$reportObj | Add-Member NoteProperty -Name "Typ" -Value $cdrom.mediatype
    			$reportObj | Add-Member NoteProperty -Name "Hersteller" -Value $cdrom.manufacturer
    			$reportObj | Add-Member NoteProperty -Name "Status" -Value $cdrom.status
    			$report += $reportObj
    			$report += "
    -----------------------------------------------------
    			"
    			$reportObj = New-Object PSObject
    			$reportObj | Add-Member NoteProperty -Name "Geraet" -Value "SPEICHERMEDIEN"
    			$reportObj | Add-Member NoteProperty -Name "Name" -Value $volume.Label
    			$reportObj | Add-Member NoteProperty -Name "Computer" -Value $processor.PSComputerName
    			$reportObj | Add-Member NoteProperty -Name "Laufwerk" -Value $volume.Caption
    			$reportObj | Add-Member NoteProperty -Name "Dateisystem" -Value $volume.FileSystem
    			$reportObj | Add-Member NoteProperty -Name "Hersteller" -Value $volume.manufacturer
    			$reportObj | Add-Member NoteProperty -Name "Seriennummer" -Value $volume.SerialNumber
    			$reportObj | Add-Member NoteProperty -Name "Blockgroeße" -Value $volume.BlockSize
    			$reportObj | Add-Member NoteProperty -Name "Kapazitaet" -Value $volume.Capacity
    			$reportObj | Add-Member NoteProperty -Name "Freier Speicher" -Value $volume.FreeSpace
    			$reportObj | Add-Member NoteProperty -Name "Maximale Dateilaenge" -Value $volume.MaximumFileNameLength
    			$reportObj | Add-Member NoteProperty -Name "Systemlaufwerk" -Value $volume.SystemVolume
    			$reportObj | Add-Member NoteProperty -Name "Autom. Einbindung" -Value $volume.Automount
    			$reportObj | Add-Member NoteProperty -Name "Bootfaehig" -Value $volume.BootVolume
    			$report += $reportObj
    			$report += "
    -----------------------------------------------------
    			"
    $reportObj = New-Object PSObject
    			$reportObj | Add-Member NoteProperty -Name "Geraet" -Value "SOUNDGERAETE"
    			$reportObj | Add-Member NoteProperty -Name "Name" -Value $sound.Caption
    			$reportObj | Add-Member NoteProperty -Name "Computer" -Value $processor.PSComputerName
    			$reportObj | Add-Member NoteProperty -Name "Bezeichnung" -Value $sound.productName
    			$reportObj | Add-Member NoteProperty -Name "Hersteller" -Value $sound.manufacturer
    			$reportObj | Add-Member NoteProperty -Name "Status" -Value $sound.Status
    			$report += $reportObj
    			$report += "
    -----------------------------------------------------
    			"
    $reportObj = New-Object PSObject
    			$reportObj | Add-Member NoteProperty -Name "Geraet" -Value "BATTERIE"
    			$reportObj | Add-Member NoteProperty -Name "Name" -Value $battery.Caption
    			$reportObj | Add-Member NoteProperty -Name "Computer" -Value $battery.PSComputerName
    			$reportObj | Add-Member NoteProperty -Name "Bezeichnung" -Value $battery.designVoltage
    			$reportObj | Add-Member NoteProperty -Name "Seriennummer" -Value $battery.deviceID
    			$reportObj | Add-Member NoteProperty -Name "Produktnummer" -Value $battery.name
    			$reportObj | Add-Member NoteProperty -Name "Status" -Value $battery.Status
    			$report += $reportObj
    			$report += "
    -----------------------------------------------------
    			"		
    $reportObj = New-Object PSObject
    			$reportObj | Add-Member NoteProperty -Name "Geraet" -Value "ERSATZ-BATTERIE"
    			$reportObj | Add-Member NoteProperty -Name "Computer" -Value $portbattery.PSComputerName
    			$reportObj | Add-Member NoteProperty -Name "Physikalischer Ort" -Value $portbattery.Location
    			$reportObj | Add-Member NoteProperty -Name "Firmware" -Value $portbattery.SmartBatteryVersion
    			$reportObj | Add-Member NoteProperty -Name "Hersteller" -Value $portbattery.Manufacturer
    			$reportObj | Add-Member NoteProperty -Name "Kapazität" -Value $portbattery.designVoltage
    			$reportObj | Add-Member NoteProperty -Name "Spannung" -Value $portbattery.designcapacity
    			$reportObj | Add-Member NoteProperty -Name "Bezeichnung" -Value $portbattery.deviceid
    			$reportObj | Add-Member NoteProperty -Name "Produktnummer" -Value $portbattery.Name
    			$report += $reportObj
    			$report += "
    -----------------------------------------------------
    			"
    			
    			
    echo "Sollen die Netzwerkadapter ebenfalls ausgelesen und in einer weiteren Datei ausgegeben werden?"		
    $Ans1 = Read-Host "Ja [Y] oder Nein [N]"
    if ($Ans1 -eq "y" -or $Ans1 -eq "Y") {
    $reportnetObj = New-Object PSObject
    			$reportnetObj | Add-Member NoteProperty -Name "Name" -Value $network.Caption
    			$reportnetObj | Add-Member NoteProperty -Name "Computer" -Value $network.PSComputerName
    			$reportnetObj | Add-Member NoteProperty -Name "Aktiviert" -Value $network.Installed
    			$reportnetObj | Add-Member NoteProperty -Name "Hersteller" -Value $network.Manufacturer
    			$reportnet += $reportnetObj
    			mkdir C:\ZZ_Systemdaten\
    			$reportnet | Out-File -Encoding utf8 C:\ZZ_Systemdaten\Netzwerkadapter.txt
    			$report | Out-File -Encoding utf8 C:\ZZ_Systemdaten\System.txt
    }
    else {
    $report | Out-File -Encoding utf8 C:\System.txt
    }
    
    
    
    

    Donnerstag, 1. September 2016 09:12
  • So etwas würde funktionieren:

    $reportnet  = @()
    
    foreach ($network in (get-WMIObject win32_networkadapter | select PSComputerName,Caption,Installed,Manufacturer)) {
        $reportnetObj = New-Object PSObject
        $reportnetObj | Add-Member NoteProperty -Name "Name" -Value $network.Caption
        $reportnetObj | Add-Member NoteProperty -Name "Computer" -Value $network.PSComputerName
        $reportnetObj | Add-Member NoteProperty -Name "Aktiviert" -Value $network.Installed
        $reportnetObj | Add-Member NoteProperty -Name "Hersteller" -Value $network.Manufacturer
        $reportnet += $reportnetObj
    }
    $reportnet | Out-File -Encoding utf8 C:\Networkadapter.txt 


    Evgenij Smirnov

    msg services ag, Berlin -> http://www.msg-services.de
    my personal blog (mostly German) -> http://it-pro-berlin.de
    Windows Server User Group, Berlin -> http://www.winsvr-berlin.de
    Mark Minasi Technical Forum, reloaded -> http://newforum.minasi.com

    In theory, there is no difference between theory and practice. In practice, there is.

    • Als Antwort markiert Leinadgnom Donnerstag, 1. September 2016 09:39
    Donnerstag, 1. September 2016 09:21
  • SUPER! Vielen Dank schonmal, genau so etwas habe ich gesucht....

    Hast du eine Idee, wie ich die Spalte innerhalb der TXT verbreitern kann, sodass der komplette Name des Adapters angezeigt wird? weil bei "Aktiviert" steht ja nur ein Boolean.

    Donnerstag, 1. September 2016 09:35
  • Moin,

    soll das für Menschen oder für Maschinen lesbar sein? Wenn Du im Endeffekt einfach eine CSV-Datei haben möchtest, dann wirst Du mit Export-CSV evtl. mehr Erfolg haben. Und wenn ein Mensch das lesen möchte, macht er die Datei einfach per Excel auf ;-)


    Evgenij Smirnov

    msg services ag, Berlin -> http://www.msg-services.de
    my personal blog (mostly German) -> http://it-pro-berlin.de
    Windows Server User Group, Berlin -> http://www.winsvr-berlin.de
    Mark Minasi Technical Forum, reloaded -> http://newforum.minasi.com

    In theory, there is no difference between theory and practice. In practice, there is.

    Donnerstag, 1. September 2016 10:58