*How to collect information from several systems and output to excel
*get-content
*split-path
*get-credential
*get-wmiobject
*get-service
*get-content
*invoke-command
*new-object
*export-csv
Simple example on how to easily collect information from multiple system and use the output directly in excel for instance.
full script from demo is here :
$CWD = Split-Path $MyInvocation.MyCommand.Definition
$servers = get-content $CWD\server.txt
$output = @()
$DomainCreds = Get-Credential
Foreach($server in $servers){
$obj = Invoke-Command -ComputerName $server -ScriptBlock {
$os = Get-WmiObject win32_operatingsystem | select -ExpandProperty caption
$bios = Get-WmiObject win32_bios | select -ExpandProperty caption
$service = Get-Service -DisplayName 'Background Intelligent Transfer Service'
$fileresult = (Get-Content c:\important.txt).Contains($env:COMPUTERNAME)
$props = @{
os = $os
bios = $bios
service = $service.Status
fileresults = $fileresult
}
New-Object psobject -Property $props
} -Credential $DomainCreds
$output += $obj
}
$newoutput = $output | select pscomputername, bios, os, fileresults, service
$newoutput | export-csv "$CWD\export.csv" -NoTypeInformation
#Get-process -name 'svchost'
Смотрите видео PowerShell S2E1 (Collect information) онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Mr Automation 19 Август 2020. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 1,693 раз и оно понравилось 27 посетителям.