PowerShell S2E1 Collect information
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=fGpsQ-y8Upo
*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'
#############################
New on site