Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- Gathers various pieces of information about a system either local or remote.
- .DESCRIPTION
- Exports all of the info to various CSV files on the local system.
- .EXAMPLE
- .\gatherinfo.ps1 -ComputerName DC1 -RunningProcesses -ComputerInfo
- .PARAMETER [-ComputerName]
- Array of systems to run the script against.
- .PARAMETER [-RunningProcesses]
- Fetches the current running processes
- .PARAMETER [-ComputerInfo]
- Fetches various computer info
- .PARAMETER [-Services]
- Fetches current running services
- .PARAMETER [-Updates]
- Fetches currently installed updates
- .PARAMETER [-LocalUsers]
- Fetches local users on the system
- .PARAMETER [-DomainUsers]
- Fetches domain users
- #>
- param (
- [string[]] $ComputerName = $env:COMPUTERNAME,
- [switch]$RunningProcesses,
- [switch]$ComputerInfo,
- [switch]$Services,
- [switch]$Updates,
- [switch]$LocalUsers,
- [switch]$DomainUsers
- )
- if ($RunningProcesses.IsPresent) {Get-Process -ComputerName $ComputerName | Export-CSV -Path "1_$($ComputerName)RunningProcesses.csv"}
- if ($ComputerInfo.IsPresent) {
- Invoke-Command -ComputerName $ComputerName -ScriptBlock
- {
- $Domain = (Get-WmiObject Win32_ComputerSsytem).Domain
- $CPUMan = (Get-WmiObject Win32_Processor).Manufacturer
- $SystemMan = (Get-WmiObject -Class win32_computersystem).Manufacturer
- $Version = (Get-WmiObject -Class win32_operatingsystem).version
- $Memory = (Get-WmiObject -Class win32_computersystem).TotalPhysicalMemory
- $Speed = (Get-WmiObject -Class win32_processor).MaxClockSpeed
- $Model = (Get-WmiObject -Class Win32_ComputerSystem).Model
- $Name = (Get-WmiObject -Class Win32_ComputerSystem).Name
- $info = New-Object psobject
- $info | Add-Member -MemberType NoteProperty -name Domain -Value $Domain
- $info | Add-Member -MemberType NoteProperty -name CPUManufacturer $CPUMan
- $info | Add-Member -MemberType NoteProperty -name SystemManufacturer $SystemMan
- $info | Add-Member -MemberType NoteProperty -name Version $Version
- $info | Add-Member -MemberType NoteProperty -name Memory $SystemMan
- $info | Add-Member -MemberType NoteProperty -name MaxClockSpeed $Speed
- $info | Add-Member -MemberType NoteProperty -name Model $Model
- $info | Add-Member -MemberType NoteProperty -name ComputerName $Name
- $info | Export-CSV -Path "2_$($ComputerName)ComputerInfo.csv"
- }
- }
- if ($Services.IsPresent) {Get-Process -ComputerName $ComputerName | Export-CSV -Path "3_$($ComputerName)RunningServices.csv"}
- if ($Updates.IsPresent) {Get-Hotfix -ComputerName $ComputerName | Export-CSV -Path "4_$($ComputerName)Updates.csv"}
- if ($LocalUsers.IsPresent) {Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount=$True" | Export-CSV -Path "5_$($ComputerName)LocalUsers.csv"}
- if ($DomainUsers.IsPresent) {Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount=$False" | Export-CSV -Path "6_$($ComputerName)DomainUsers.csv"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement